QuizNot attempted
Render vs useLayoutEffect vs useEffect order
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
render,useLayoutEffect,useEffect
- Render runs first
- then in the commit phase React applies DOM changes and synchronously runs layout effects before the browser paints
- passive
useEffects run after paint. - So:
render,useLayoutEffect,useEffect. - Not useEffect before layout: passive effects are deferred.
- Not layout before render: effects can't run before the component has rendered.
- Not non-deterministic: the order is guaranteed.