QuizNot attempted
Previous value with a ref
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
Now: 2, Before: 1
- Effects run after render, so each render displays
prevCount.currentfrom the previous render's effect, one step behind: atcount = 2it showsBefore: 1. - Not Before: 2: the effect writing 2 runs after this render is painted.
- Not Before: 0: the effect after the
count = 1render already stored 1. - Not undefined: only the very first render shows undefined.