You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classExampleextendsReact.Component{componentDidMount(){this.setState(()=>{console.log(`Set state calls in ${this.props.name}`);});}render(){return<div>{this.props.name}</div>;}}constApp=()=>(<div><React.StrictMode><Examplename="StrictMode"/></React.StrictMode><Examplename="Normal"/></div>);
Will output
Set state calls in StrictMode
Set state calls in StrictMode
Set state calls in Normal
What is the expected behavior?
setState function should only be called once in StrictMode
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React: 16.4.0, 16.3.2
Browsers: Chrome, Firefox, Safari
The text was updated successfully, but these errors were encountered:
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Calling setState with a function gets called twice on a components that is wrapped in React.StrictMode.
CodeSandbox (https://codesandbox.io/s/zl9rv0mmkx)
Will output
What is the expected behavior?
setState function should only be called once in StrictMode
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React: 16.4.0, 16.3.2
Browsers: Chrome, Firefox, Safari
The text was updated successfully, but these errors were encountered: