Missing useEffect Cleanup
useEffect with subscriptions/timers but no cleanup
warningReliability
missing-useeffect-cleanupWhy this matters
Without cleanup, subscriptions and timers keep running after the component unmounts. This causes memory leaks, stale state updates, and 'can't update unmounted component' errors.
✗ Bad
useEffect(() => {
const interval = setInterval(() => {
fetchNotifications();
}, 5000);
// No cleanup — interval runs forever
}, []);✓ Good
useEffect(() => {
const interval = setInterval(() => {
fetchNotifications();
}, 5000);
return () => clearInterval(interval);
}, []);How to fix
Return a cleanup function from every useEffect that creates subscriptions, timers, event listeners, or WebSocket connections.