React has only one method that gets called when a component is unmounted:
What is happening with each method?
componentWillUnmount() is invoked immediately before the component is removed from the DOM. Its a good place to perform cleanup- such as long running processes that you set up in componentDidMount(), invalidating timers, removing subscriptions, etc.
Example below is cleaning up an event listener: