All 35 Bugs /
0/35 Fixed ✓
ReactEasy~10 min

Stale State in Rapid Counter Clicks

What's Broken (Symptom)

Clicking the "+3 Batch Increment" button calls `increment()` three times in one click, yet the counter only increases by `+1`!

Expected Behavior

  • Use a functional updater `setCount(prev => prev + 1)` inside batched updates.
  • Clicking `+3 Batch Increment` once moves `0 -> 3`, and clicking twice reaches `6`.
  • Single `+1` increment button continues to work accurately.

Debugging Hints (0/2 used)

Try spotting the bug in the editor first. Need a nudge? Reveal Hint 1 anytime.

Root Cause Breakdown

Pass all 3 automated verification checks on the right to unlock the full Root Cause explanation.

Automated Bug Verification

3 Checks Ready
  • Single "+3 Batch Increment" click transitions count 0 -> 3All three queued updates must apply.
  • Two "+3 Batch Increment" clicks reach count 6Sequential batched clicks accumulate properly.
  • Single "+1" button increments to 7Regular +1 button continues working cleanly.
bugfix.html
Live Sandboxed PreviewCtrl + Enter to verify
Console Output0 log(s)
No console output yet. Run Preview or Verify Bug Fix.