Skip to content

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.

  1. Run useEffect callbacks
  2. Browser paints the frame
  3. Commit, layout: run useLayoutEffect callbacks
  4. Commit, mutation: apply DOM changes
  5. Render phase: call components and diff the new tree (pure, interruptible)
Show answer & explanation

Correct order:

  1. Render phase: call components and diff the new tree (pure, interruptible)
  2. Commit, mutation: apply DOM changes
  3. Commit, layout: run useLayoutEffect callbacks
  4. Browser paints the frame
  5. Run useEffect callbacks

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.