A live ticker displays a number that should increment every second automatically from the moment the component mounts.
The ticker reaches 1 after the first second and then freezes. It never increments past 1 no matter how long you wait.
The callback passed to setInterval captures variables at the time it is created - what value does it always see?
The callback passed to setInterval captures variables at the time it is created - what value does it always see?
Why this fixes it
The interval callback closed over `count` at mount, permanently capturing `0`. Every tick called `setCount(0 + 1)` which is always `1`. After the first tick count was already `1`, so React's equality check bailed out - the counter froze. Replacing with `setCount((c) => c + 1)` uses a functional updater that receives the actual current state from React's queue on each tick, so each call correctly increments from the real current value.