OrderNot attempted
From setState to pixels
A state update happens. Order what React and the browser do next.
Drag the rows, or use the arrows, to put them in order from first to last.
- Run
useEffectcallbacks - Browser paints the frame
- Commit, layout: run
useLayoutEffectcallbacks - Commit, mutation: apply DOM changes
- Render phase: call components and diff the new tree (pure, interruptible)
Show answer & explanation
Correct order:
- Render phase: call components and diff the new tree (pure, interruptible)
- Commit, mutation: apply DOM changes
- Commit, layout: run
useLayoutEffectcallbacks - Browser paints the frame
- Run
useEffectcallbacks
Render is pure and can be paused or thrown away (concurrent rendering). Commit is synchronous. Layout effects run before paint, so they can measure and fix layout without flicker; passive effects run after paint so they never block it.