ReactHard

What is concurrent rendering?

Concurrent rendering, introduced in React 18, lets React prepare multiple versions of the UI at once and interrupt, pause, resume or abandon rendering work. Urgent updates (typing, clicking) can jump ahead of non-urgent ones (transitions), so the app stays responsive during heavy renders. It is enabled by createRoot and used through features like useTransition, useDeferredValue and Suspense.

Before: synchronous rendering

Once React started rendering an update, it ran to completion. A slow render (filtering 10,000 items) blocked the main thread, so keystrokes lagged.

With concurrent rendering

  • Rendering is split into small units of work (fibers). React yields to the browser between units.
  • Updates have priorities: discrete input is urgent; transitions are interruptible.
  • An in-progress transition render can be thrown away if newer data arrives.
  • The DOM is only updated in the commit phase, so users never see half-rendered trees.

Features built on it

  • useTransition / startTransition and Actions.
  • useDeferredValue.
  • Suspense for data, use(promise), and streaming server rendering with selective hydration.
  • <Activity> (React 19.2) rendering hidden content at low priority.
  • <ViewTransition> animations (stable in 19.3).
  • React 19.3 renders separate transitions independently.

What it requires from your code

  • Pure render functions (React may render more than once).
  • Effects with proper cleanup.
  • External stores read through useSyncExternalStore to avoid tearing.

It is opt-in per update

Concurrency only kicks in for updates you mark as transitions or deferred; ordinary updates still render synchronously.

Code example

tsx
1import { useState, useTransition } from "react";
2
3function SlowTab({ name }: { name: string }) {
4 const items = Array.from({ length: 300 }, (_, i) => i);
5 return (
6 <ul>
7 {items.map((i) => {
8 const start = performance.now();
9 while (performance.now() - start < 1) {} // 1ms per item: ~300ms total
10 return <li key={i}>{name} item {i}</li>;
11 })}
12 </ul>
13 );
14}
15
16export function Tabs() {
17 const [tab, setTab] = useState("home");
18 const [isPending, startTransition] = useTransition();
19
20 function select(next: string) {
21 // Interruptible: clicking another tab mid-render abandons this one
22 startTransition(() => setTab(next));
23 }
24
25 return (
26 <div>
27 {["home", "posts", "contact"].map((t) => (
28 <button key={t} onClick={() => select(t)} aria-pressed={tab === t}>{t}</button>
29 ))}
30 {isPending && <span> loading…</span>}
31 {tab === "posts" ? <SlowTab name="Post" /> : <p>{tab} content</p>}
32 </div>
33 );
34}

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the React set.

Open in study app