Question · JavaScript and React course · Module 5: useEffect and Custom Hooks
Testing Cleanup in useEffect
What is the best way to test whether the cleanup function in useEffect works correctly?
Answer options
- Mount the component and check if the effect ran
- Unmount the component and verify that cleanup was called (e.g., clearInterval)
- Check the browser console for errors
- Run the component in production mode and observe behavior
You can check the correct answer by solving this task in the CodeWorlds game.