React & Modern Frontend (445 Qs)•Part 1: Core React, JSX & Component Architecture (1 - 77)
What is the main goal of React Fiber?
The goal of React Fiber is to increase its suitability for areas like animation, layout, and gestures. Its headline feature is incremental rendering: the ability to split rendering work into chunks and spread it out over multiple frames.
Its main goals are:
- Incremental Rendering – Breaks work into chunks for smoother updates.
- Interruptible Rendering – Pauses and resumes rendering to keep the UI responsive.
- Prioritization – Handles high-priority updates (e.g. animations) before low-priority ones.
- Concurrency Support – Enables working on multiple UI versions simultaneously.
- Better Error Handling – Supports component-level error boundaries.
- Suspense Support – Allows waiting for async data before rendering.
- Improved DevTools – Enables better debugging and performance tracking.
Practical Code Example
jsx
// React Fiber Goal: Prevent main thread freezing during large UI renders
import { useTransition, useState } from 'react';
function SearchResults() {
const [query, setQuery] = useState('');
const [isPending, startTransition] = useTransition();
function handleChange(e) {
// High priority: update input field immediately
setQuery(e.target.value);
// Low priority: filter 10,000 items (Fiber can pause this work!)
startTransition(() => {
// Background filtering...
});
}
return <input value={query} onChange={handleChange} />;
}