MODULO Full Stack Web Development: The Ultimate Master SagaTHEORY
Update a counter from its previous value
Create a React counter starting at zero. In a click handler call setCount(n => n + 1) twice. Then replace both calls with setCount(count + 1) and repeat from zero.
Check your work
The first version shows 2 and the second shows 1 after one click. Updaters receive the result of earlier queued updates. Both direct replacements read count from the same render.
