This project is part of Week 7 and implements React’s modern concurrent rendering architecture.
Overview
Build a clone of React’s core reconciler implementing the Fiber architecture with full hooks support. This project covers React’s modern concurrent rendering model including time slicing, Suspense, and priority-based updates.Project requirements
Architecture
Fiber reconciler with work loop
Hooks
Complete hooks implementation
Concurrent
Time slicing and Suspense
Priority
Lane-based priority model
Core components
Fiber reconciler
Implement the Fiber architecture:
- Work loop and unit of work
- Reconciliation phases: render and commit
- Effect list construction
- Priority levels and lane model
Hooks implementation
Build all core hooks:
- Hooks queue and cursor
- useEffect cleanup and dependency checking
- useRef mutable container
- useCallback/useMemo memoization
- Custom hook composition
Fiber architecture
Fiber is React’s reconciliation algorithm that enables incremental rendering and prioritization.
Work loop
The work loop processes units of work (Fibers) and can be interrupted:Reconciliation phases
Render phase
Build Fiber tree, can be interrupted and restarted. No side effects.
Commit phase
Apply changes to DOM synchronously. Cannot be interrupted.
Hooks implementation
useState
useState
Implement state management with queue-based updates. Handle multiple state updates in a single render and batching.
useEffect
useEffect
Track effects during render, execute after commit. Implement cleanup functions and dependency array comparison for optimization.
useRef
useRef
Create mutable container that persists across renders without triggering re-renders.
useCallback / useMemo
useCallback / useMemo
Implement memoization with dependency tracking. Only recompute when dependencies change.
Custom hooks
Custom hooks
Enable composition of primitive hooks into reusable custom hooks.
Hooks queue architecture
Hooks rely on a cursor and queue system to maintain state across renders.
- Hooks must be called in the same order every render
- Each hook stores its state in a linked list
- Cursor tracks current position in the hooks list
- Hook state persists on the Fiber node
Concurrent features
Time slicing
Break rendering work into chunks that can be interrupted. Yield to browser between chunks to keep UI responsive.
Suspense
Allow components to “suspend” rendering while waiting for async data. Display fallback UI during loading.
useTransition
Mark updates as transitions to deprioritize them. Keep UI responsive during heavy updates.
Priority model
Lanes
React uses “lanes” for fine-grained priority control.
High priority
User input and animations (synchronous).
Normal priority
Standard updates like data fetches.
Low priority
Background updates and transitions.
Effect list construction
Build a linked list of Fibers with effects during reconciliation for efficient commit phase.
- Placement (new nodes)
- Update (changed nodes)
- Deletion (removed nodes)
Deliverables
- Working React clone with Fiber reconciler
- Complete hooks implementation (useState, useEffect, useRef, useCallback, useMemo)
- Time slicing with work interruption
- Suspense for async rendering
- useTransition and useDeferredValue
- Lane-based priority system
- Effect list and commit phase
- Automatic batching of updates
- Test suite demonstrating all features
- Examples showing concurrent rendering benefits
Success criteria
- Fiber work loop can be interrupted and resumed
- All hooks work correctly with proper state management
- Hooks maintain call order invariants
- useEffect cleanup runs at correct times
- Dependency arrays properly detect changes
- Suspense displays fallbacks during loading
- Time slicing keeps UI responsive during heavy renders
- Priority system correctly prioritizes high-priority updates
- Commit phase applies all effects synchronously
- Component tree renders correctly with concurrent features