The componentWillUnmount() method allows us to execute the React code when the component gets destroyed or unmounted from the DOM (
How do you call a component unmount?
On clicking the 'Delete User' button, the User component will get unmounted from the DOM tree and before destroying the User component, the componentWillUnmount method will be called.
What does component unmount mean?
componentWillUnmount is the last function to be called immediately before the component is removed from the DOM. It is generally used to perform clean-up for any DOM-elements or timers created in componentWillMount . At a picnic, componentWillUnmount corresponds to just before you pick up your picnic blanket.