componentWillUnmount

componentWillUnmount is invoked just before the component is removed from the DOM. Here are some common use cases for this method:

  • Removing event listeners
  • Canceling active network requests
  • Removing timers

We are going to use componentWillUnmount in our app to make sure our timer is stopped and removed. Let's add the following in the App class after the componentDidMount method:

public componentWillUnmount() {
clearInterval(this.timer);
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.195.29