Kar started this conversation 3 months ago.
Missing cleanup in useEffect — leaking timers or subscriptions
I register a window resize listener or interval in useEffect but forget to clean it up. Over time, event handlers pile up or continue after unmounting, causing performance issues.
Digiaru
Posted 3 months ago
Without cleanup, effects persist beyond component life and retain stale callbacks and memory, leading to leaks or duplicated behavior ([turn0search11], [turn0search6]). Fix: jsx Copy code useEffect(() => { window.addEventListener('resize', handleResize); const id = setInterval(tick, 1000); return () => { window.removeEventListener('resize', handleResize); clearInterval(id); }; }, []);