Effect Cleanup
Return a function to clean up timers and listeners.
Example
useEffect(() => {
const id = setInterval(() => console.log("tick"), 1000);
return () => clearInterval(id);
}, []);Exercise
Cleanup function.
return () => (id);
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.