QuizNot attempted
Event listener reading stale state
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
0
- With
[]the effect ran once, sohandleResizeis the function created in the mount render and itsvalueis frozen at0 - the listener is still attached, it just reads stale state.
- Not 3: the listener never sees later renders.
- Not 'listener removed': cleanup only runs on unmount.
- Not 1: there is no render where the closure captured 1.
- Fix: add
valueto deps, read from a ref, or useuseEffectEvent.