Question presented to candidate: "React Fiber is described as a rewrite of the reconciler. What actually changed, and why?"
What a strong answer should cover:
- Fiber is React's internal representation of a unit of work — one JavaScript object per element in the tree, plus the reconciler that walks them.
- The problem it solved: the old reconciler used recursion, so a render could not be interrupted. Once started, it ran to completion and blocked the main thread.
- Fiber replaces recursion with a linked-list tree — each node has
child,siblingandreturnpointers — which turns the traversal into a loop over an explicit structure rather than a call stack. - Because the position is data rather than stack frames, React can stop between units, yield to the browser, and resume later — that is what makes concurrent features possible.
- Double buffering: React keeps a pair of fibers per position (
currentandalternate), building the next tree into the spare one, so the committed tree is never partially mutated. - Two phases: the render phase is interruptible and produces a list of effects; the commit phase is synchronous and applies them.
- Each fiber carries
memoizedState(the hooks linked list),memoizedProps,flags(what changed) andlanes(priority). - Fiber is an implementation detail — do not reach into it in application code.
Clarifying questions expected:
- "Do you want the data structure, or the scheduling consequences?" — they are separable answers.
Code / implementation expected: No. Fiber is internal; describing the structure and what it enables is the answer.