React Fiber Architecture
React Fiber is React’s internal architecture and reconciliation engine (introduced in React 16).
Fiber allows React to do incremental rendering (split work into small chunks) instead of blocking the UI for long renders.
Fiber is built to support scheduling — React can decide when to render and what to render first.
Fiber introduces a virtual stack (Fiber nodes) so React can pause, resume, or discard rendering work.
React’s work is divided into two major phases:
- Render Phase (can be interrupted in concurrent rendering): builds the new Fiber tree and calculates changes.
- Commit Phase (non-interruptible / sync): updates the DOM + runs effects safely.
Render Phase details:
- Builds the workInProgress Fiber tree
- Performs diffing (reconciliation)
- Can yield to the browser if higher priority tasks exist (concurrent rendering)
Commit Phase details:
- Applies changes to the DOM (Placement / Update / Deletion)
- Runs lifecycle methods and layout effects synchronously (useEffect callbacks are flushed afterwards, usually after paint)
- Must be synchronous to avoid UI tearing
Each Fiber node is a unit of work and stores:
- Component type (Function / Class / Host like div)
- Props and state
- Tree pointers: parent, child, sibling
- Alternate pointer for double buffering
- Side effects flags (update / placement / deletion)
// Simplified Fiber node shape
const fiber = {
tag: 'FunctionComponent' | 'ClassComponent' | 'HostComponent',
type: 'div' | MyComponent,
key: null,
stateNode: DOMNode | ComponentInstance,
return: parentFiber,
child: firstChildFiber,
sibling: nextSiblingFiber,
pendingProps: {},
memoizedProps: {},
memoizedState: {},
alternate: previousFiberVersion,
flags: Placement | Update | Deletion,
subtreeFlags: childEffects
};
React uses double buffering by keeping 2 trees:
- current tree (already shown on screen)
- workInProgress tree (new work being prepared)
After commit, workInProgress becomes the new current tree.
React Fiber enables modern features like:
- Concurrent Rendering (React 18)
- Time Slicing
- Suspense
- Selective Hydration
- Transitions (useTransition)
Concurrent Rendering (React 18):
React can prepare multiple UI updates in the background and commit the best result when ready.
This improves perceived performance and keeps UI responsive.
Time Slicing:
React splits long rendering work into chunks and yields control to the browser to handle input/paint.
This prevents the UI from freezing during heavy renders.
Interruptible Rendering:
React can pause low priority work to immediately process high priority work like typing, clicking, scrolling.
Automatic Batching (React 18):
Multiple state updates are grouped into a single render for better performance, even inside timeouts, promises, and native event handlers (when your app uses createRoot).
setTimeout(() => {
setCount(1);
setFlag(true);
setUser({});
}, 1000);
// Before React 18 (ReactDOM.render): 3 separate renders for the code above
// React 18+ (createRoot): batched into 1 render
The reconciliation algorithm compares:
- Old Fiber tree (current)
- New Fiber tree (workInProgress)
Then it calculates the minimal DOM operations needed.
Effect Flags help React track what needs to happen:
- Placement → create/insert DOM node
- Update → update DOM attributes/props
- Deletion → remove node + cleanup
Priority & Scheduling (Lanes):
React uses lanes to represent priorities of updates (urgent vs non-urgent).
Examples of lane types: Sync, Input, Default, Transition, Idle.
// Example lanes (simplified, real values differ)
const SyncLane = 0b0000000000000000000000000000001;
const InputContinuousLane = 0b0000000000000000000000000000100;
const DefaultLane = 0b0000000000000000000000000010000;
const TransitionLane = 0b0000000000000000000100000000000;
const IdleLane = 0b0100000000000000000000000000000;
React uses its own scheduler to decide when to run work and when to yield to the browser.
It behaves like a smart task manager for UI rendering.
useTransition is built on Fiber scheduling:
It marks updates as non-urgent so React can keep UI fast.
// useTransition example
const [isPending, startTransition] = useTransition();
function handleSearch(value) {
// urgent update
setInputValue(value);
// non-urgent update
startTransition(() => {
setSearchQuery(value);
});
}
Suspense + Fiber:
Fiber makes it possible for React to pause rendering while waiting for async data or code split bundles.
This enables smooth loading states without manual state handling.
// Suspense nesting example
function ProfilePage() {
return (
<Suspense fallback={<Spinner />}>
<ProfileDetails />
<Suspense fallback={<PostsSpinner />}>
<ProfileTimeline />
</Suspense>
</Suspense>
);
}
Fiber Work Loop:
React processes the Fiber tree using two main steps:
- performUnitOfWork → start working on a fiber
- completeUnitOfWork → finalize a fiber and bubble effects upward
// Simplified concurrent work loop
// (React's real scheduler uses MessageChannel, not requestIdleCallback)
function workLoop(deadline) {
while (nextUnitOfWork && deadline.timeRemaining() > 1) {
nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
}
if (!nextUnitOfWork && wipRoot) {
commitRoot();
}
requestIdleCallback(workLoop);
}
Why Fiber is important?
Because it makes React capable of building smooth, responsive apps even when components are large and updates are frequent.
Summary: Fiber enables
- Incremental rendering
- Scheduling + priority updates
- Suspense + streaming SSR
- Concurrent features
- Better performance + responsiveness