Skip to content

Rule · Smoothness

React keeps committing while the page is idle

smooth/react-idle-commitswarnvoid smoothupdated

Why it matters

Timers, intervals or animation state that re-render React with no input keep the main thread busy and drain battery, and every commit competes with the next scroll or tap. The rendered UI is often not even on screen.

How to fix it

Pause the source while it is not visible (IntersectionObserver, document.visibilityState), animate with CSS or WAAPI instead of state, and move ticking values into a ref or a small leaf component.

Example

ts
useEffect(() => {
  if (!visible) return;
  const id = setInterval(tick, 1000);
  return () => clearInterval(id);
}, [visible]);

References

void smooth reports 18 rules in this category. How the page feels after it loads: dropped frames during a scripted scroll, long animation frames, INP of real clicks, shifts after input, animated layout properties, idle rAF loops and reduced-motion handling.