react组件中console打印两次的原因
当应用程序包装在<React.StrictMode>
中时,您的组件将在开发环境中呈现两次。这用于错误/警告检测。
Strict模式将有意调用以下类组件函数两次:构造函数、render
方法和shouldComponentUpdate
方法。
阅读文档中有关严格模式的更多信息。
当应用程序包装在<React.StrictMode>
中时,您的组件将在开发环境中呈现两次。这用于错误/警告检测。
Strict模式将有意调用以下类组件函数两次:构造函数、render
方法和shouldComponentUpdate
方法。
阅读文档中有关严格模式的更多信息。