Why does React state still have the old value immediately after a setter?
A render receives a snapshot of state. Calling setCount schedules another render; it does not replace count inside the running handler. When the next value depends on the previous one, use an updater such as setCount(previous => previous + 1). Three queued updater calls increment three times; three calls using the same count + 1 snapshot do not.