Since isMounted()
is being officially deprecated, you can do this in your component:
componentDidMount() {
this._ismounted = true;
}
componentWillUnmount() {
this._ismounted = false;
}
This pattern of maintaining your own state
variable is detailed in the ReactJS documentation: isMounted is an Antipattern.