I am learning reactJs, after reading this part of the docs:
An easy migration strategy for anyone upgrading their code to avoid isMounted() is to track the mounted status yourself. Just set a _isMounted property to true in componentDidMount and set it to false in componentWillUnmount, and use this variable to check your component's status.
Does that mean the _isMounted
value has to be stored in state
?
I have this so far:
isMounted: function(){
this.setState({ _isMounted: true });
},
componentDidMount: function() {
if(this.state._isMounted) { // This is bad.
this.setState({...});
}
},