Events and State in React: useState, Immutable Updates and When Re-renders Happen
In React state is a snapshot per render: setState does not change the variable, it asks for the next render; an update computed from the previous value needs an updater function, and objects and arrays always need a new reference. We add a quantity picker and a cart to the Bookstore catalog and show with render logs that three setAmount(amount + 1) calls give 2, that a mutated cart reaches the screen late and that three updates in one event become one render.
15 Nov 2026
·
12 min
·
6