Why this matters

The bug. useEffect with [] only runs on mount, so its inner closure captures count from the first render. Every interval tick sets count to 0 + 1.

The fix. Use the *functional updater*: setCount(c => c + 1). React passes the latest value, so the closure no longer needs to know what count is.

Alternative. Add count to the dep array — but that recreates the interval on every tick, which is slightly wasteful and re-introduces drift.

Review heuristic

Every closure that captures a value from a render or a setup phase needs an honest answer to the question: is this value allowed to change between when I closed over it and when I run? If yes, the closure is wrong; switch to a ref, a functional updater, or a fresh read.