A counter starts at zero and increments once on mount, settling at 1.
The counter rockets upward continuously and never settles.
Think about what's in the dependency array and what happens after the effect runs.
Think about what's in the dependency array and what happens after the effect runs.
Why this fixes it
The effect read `count` from its closure and called `setCount(next)`, which updated `count`, which was listed as a dependency, which caused the effect to re-run - a render loop with no exit. Changing the dependency array to `[]` and using `setCount(prev => prev + 1)` breaks the cycle: the effect runs only once on mount and the functional updater removes the need to close over `count` at all.