QuizNot attempted
Setting the same value twice
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
2
- Click 1 changes 0→1 and both identical updates batch into one render, so
renderCountbecomes 2 and the button shows2. - Click 2 sets the value it already has, so React bails out and commits nothing
- the DOM still shows
2. - Not 3: React may call the component once before bailing out (so the module counter can reach 3), but that render is thrown away and never committed.
- Not 4: no click produces two renders.
- Not 1: click 1 really re-renders.
- Never rely on render counts.