QuizNot attempted
setState inside useLayoutEffect
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
render 0,render 1— user never sees0painted (layout effect updates before paint)
- The update scheduled in
useLayoutEffectis processed synchronously before the browser paints, sorender 0andrender 1both log but only1ever reaches the screen. - Not 'render 0 only, user sees 0': that describes
useEffect, which runs after paint. - Not an infinite loop: the
count === 0guard stops after one update. - Not 'render 1 only': the initial render with 0 still runs.