Skip to content

Rule · Lint

setTimeout / setInterval called in a component body

lint/timer-in-rendererrorvoid lintupdated

Why it matters

The render body runs on every render (and twice in Strict Mode), so each render schedules another timer that is never cleared: leaks, duplicated state updates and render storms.

How to fix it

Start timers in useEffect and clear them in the cleanup function.

Example

tsx
useEffect(() => {
  const id = setInterval(tick, 1000)
  return () => clearInterval(id)
}, [])

References

void lint reports 67 rules in this category. Static source checks with no browser: Tailwind v4 silent failures, Next.js 16 API traps, React render-body bugs, accessibility markup, SEO files and motion hygiene.