This is a quick reminder that you should always (1) remove event listeners and (2) clear timeouts/intervals when you don't need them any more. Doing so makes your app more performance, stable and secure.

Do a quick audit of your project(s) and ensure you have an equal number of

  • .addEventListener() as .removeEventListener()
  • setTimeout() as clearTimeout()
  • and setInterval() as clearInterval().

In React, in most cases removing event listeners and clearing timeouts/intervals should go inside componentWillUnmount unless there is a need to do it earlier.