![](/img/trans.png)
[英]React-google-recaptcha does not appear in the modal when the component is rendered
[英]React JS: Avoid the Modal to be executed when the component is rendered
我在React中使用Modals时注意到的是呈现组件时,即使可见状态为false,也会执行Modal的主体。
例:
render() {
return (
<Modal
title="Basic Modal"
visible={false}
onOk={this.handleOk}
onCancel={this.handleCancel}
>
<p>Some contents...</p>
{console.log('visible is false but content is being executed!')}
</Modal>
);
}
我只想在可见道具为true时执行整个Modal。 有办法吗?
我正在使用此基本的模态组件: https : //ant.design/components/modal/
这与Modal无关,而与渲染Modal的组件有关,为什么父组件会重新渲染,console.log将始终执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.