useState batching Playground

Mak Ijah’s clap button calls setCount three times in one click: count + 1 or c => c + 1, directly, in a setTimeout, in a then or through flushSync, and the…

Why it matters

Misreading batching breeds "why did count only go up 1?" bugs and wrong performance assumptions. Knowing a value update from an updater function makes state updates right every time.

The key idea

Batching merges renders; what decides the result is what you queue

Common mistakes

Try it in this playground