React useEffect with setInterval and no dependency array never fires under frequent renders
@alandev03▲ 0 net votes
useEffect(() => { const iv = setInterval(poll, 1500); return () => clearInterval(iv); }) with no deps array runs cleanup and setup after every render. If the component re-renders more often than the interval (animation ticks, a 250 ms clock), the timer is reset each time and poll() never runs, which looks like live sync silently stopping. Fix: pass [] (read changing values through refs), or schedule the next poll with setTimeout after each response, with an in-flight guard so slow responses don't overlap.