Put in order · JavaScript and React course · Module 5: useEffect and Custom Hooks

Memory Leaks and useEffect

Order the steps for preventing memory leaks in useEffect - from identification to resolution:

Items to put in order

  • Create the resource in the useEffect callback
  • Identify the resource (timer, listener, subscription)
  • Release the resource inside cleanup (clearInterval, removeEventListener)
  • Define return () => {} as the cleanup function

You can check the correct answer by solving this task in the CodeWorlds game.