What is React Fiber?

HardReact FundamentalsTheory Question

Hint

The old reconciler used the JavaScript call stack. What does React gain by keeping its own linked list of work units instead?

Full Answer

Fiber is React's reconciler since React 16. The old "stack" reconciler walked the tree recursively and couldn't stop until it finished. Fiber turns each component into a fiber — a plain object describing one unit of work — linked by child, sibling and return pointers. Because React walks this list itself instead of using the call stack, it can pause, resume, prioritize or discard work.

// Simplified shape of a fiber
{
  type: Counter,          // component or host tag ('div')
  key: null,
  stateNode: null,        // DOM node for host components
  child: fiberA,          // first child
  sibling: fiberB,        // next sibling
  return: parentFiber,    // parent
  pendingProps: { step: 1 },
  memoizedState: hooksList,
  lanes: 0b0001,          // priority of pending work
  alternate: currentFiber // the other tree's copy
}

Double buffering: React keeps a current tree (on screen) and builds a work-in-progress tree. When the work-in-progress tree is complete, React commits it in one go and the two swap roles via alternate.

Two phases: the render phase (building the work-in-progress tree) can be split up and interrupted; the commit phase (DOM changes, layout effects) runs synchronously.

💡 Fiber is what makes concurrent features — transitions, Suspense, useDeferredValue — possible. It's an internal architecture: you never create fibers yourself.

More React Fundamentals Questions

Practice this in a timed sprint

5 free questions, no signup required