7.4: Unmount Methods
Unmount Phase Method
componentWillUnmount() *
componentWillUnmount()
is called right before a component is unmounted and destroyed. Perform any necessary cleanup in this method, such as invalidating timers, canceling network requests, or cleaning up any subscriptions that were created in componentDidMount()
. If we don't take the time to remove events we can create memory leaks in our system which will slow down your application and make performance terrible. React will often do a good job of telling you that you're trying to update something that is no longer mounted if you forget to do this, so if you see this message make sure you've cleaned up everything in componentWillUnmount()
for your components.
Last updated