Skip to the page

How React renders · senior

Fiber: how React splits rendering into units of work

Fiber is React's internal rewrite of reconciliation: each component instance is a "fiber" object linked by child, sibling and return pointers, so React can do render work in small pieces, pause for urgent work, and throw away work it no longer needs.

The notes

What you must know

  • The old "stack" reconciler was recursive and synchronous: once a big render started it blocked the main thread until it finished.
  • A fiber is a plain object per component instance: type, props, state and the hooks list (memoizedState), effect flags, lanes (priority), and pointers child, sibling, return, plus alternate.
  • Because the tree is a linked list, React walks it with a loop (begin work going down, complete work going up) and can stop between units and continue later. This is cooperative scheduling on ONE thread, not multithreading.
  • Double buffering: React builds a work-in-progress tree from the current tree; on commit the work-in-progress tree becomes current.
  • Lanes are priority bits: a click is urgent (blocking lane); startTransition updates use transition lanes and can be interrupted.
  • Render work is interruptible; the commit phase is not.
  • Fiber is the base for transitions, Suspense, selective hydration and <Activity>.

The red pen

Common traps: mistake → fix

  • Mistake: "Fiber is the new virtual DOM"

    Fix: it is the reconciler's data structure and work loop.

  • Mistake: "Fiber renders on multiple threads"

    Fix: it is time-slicing on the main thread; JavaScript still runs on one thread.

  • Mistake: "Commit can be interrupted too"

    Fix: only render work can be paused or discarded; commit runs in one go so the DOM is never half-updated.

Easy to hard

Questions interviewers ask, easy to hard

  1. What problem did Fiber solve compared with the old reconciler?
  2. What is inside a fiber node?
  3. What are current and workInProgress?
  4. What are lanes, and how does an urgent click interrupt a transition render?
  5. How does Fiber make Suspense and selective hydration possible?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview