其他分享
首页 > 其他分享> > react组件中console打印两次的原因

react组件中console打印两次的原因

作者:互联网

当应用程序包装在<React.StrictMode>中时,您的组件将在开发环境中呈现两次。这用于错误/警告检测。

Strict模式将有意调用以下类组件函数两次:构造函数、render方法和shouldComponentUpdate方法。

阅读文档中有关严格模式的更多信息。

标签:console,render,模式,两次,react,Strict,组件,构造函数
来源: https://www.cnblogs.com/gdluck/p/16128718.html