Why React Needed Fiber
Early versions of React used a stack-based reconciliation model:
- Rendering was synchronous
- Once started, it could not be interrupted
- Large updates blocked the main thread
š Result: dropped frames and unresponsive UI.
What is React Fiber?
React Fiber is a reimplementation of the call stack in JavaScript, transforming React into a cooperative scheduler.
Instead of processing the entire tree at once, React now:
- Breaks work into smaller units
- Schedules them based on priority
- Can pause, resume, or discard work
Core Idea: Work Units
Each component becomes a unit of work, allowing React to:
- Split rendering into chunks
- Yield control back to the browser
- Keep UI responsive
Key Capabilities Introduced
š¹ Incremental Rendering
- Breaks rendering into smaller tasks
- Avoids long blocking operations
š¹ Time Slicing
- React yields control every few milliseconds
- Keeps input, animations, and scrolling smooth
š¹ Concurrency
- Multiple UI states can be prepared simultaneously
- High-priority updates interrupt low-priority work
Fiber Architecture (Visual)
š Each node above is a Fiber Node (unit of work)
Fiber Node Structure
Each component is represented by a Fiber Node containing:
childā first childsiblingā next siblingreturnā parent
š This forms a linked structure, not a simple tree.
š Dual Tree (Double Buffering)
React maintains two trees:
- Current Tree ā UI currently on screen
- Work-in-Progress Tree ā UI being prepared
Flow
š This ensures smooth updates without breaking UI
š¦ Lane-Based Priority System
React assigns updates to lanes (bitmasks):
- Discrete ā clicks, typing (highest priority)
- Continuous ā scroll, drag
- Default ā data updates
š High-priority updates can interrupt lower ones
Rendering Phases
1. Render Phase (Interruptible)
- Builds the new tree
- Can be paused, resumed, or aborted
2. Commit Phase (Synchronous)
- Applies changes to the DOM
- Cannot be interrupted
End-to-End Flow
User Action ā Schedule Update (Lane Priority) ā Render Phase (Fiber Work Loop) ā Pause / Resume if needed ā Commit Phase ā DOM Updated
Why Fiber Matters
Fiber enables React to:
- Avoid blocking the main thread
- Prioritize important updates
- Deliver smoother user experiences
- Support modern features like streaming and concurrency
Key Takeaway
React is no longer just a rendering library ā it is a scheduler for UI work.