Mastery of useEffect
- Dependencies: React re-runs the effect when items in the dependency array change.
- Cleanup: Return a function to clean up subscriptions or timers to prevent memory leaks.
jsx useEffect(() => { const timer = setInterval(() => {}, 1000); return () => clearInterval(timer); }, []);