Warning.js:45 Warning: Setstate(...): Can Only Update A Mounted Or Mounting Component
I am new to js I am trying to use this.setState({ but I am getting a warning. can you guys tell me why I am getting the below warning warning.js:45 Warning: setState(...): Can on
Solution 1:
Change:
componentWillMount
to
componentDidMount
Components have to be mounted before they can do stuff like set state.
Solution 2:
Warning appears because you use setState in componentWillMount lifecycle. Take a look at this tutorial https://facebook.github.io/react/tutorial/tutorial.html here you can find how correctly to use setState()
Post a Comment for "Warning.js:45 Warning: Setstate(...): Can Only Update A Mounted Or Mounting Component"