~/alexsh.blog

$ cat react-internals/06-concurrent-features.md

Concurrent Features

February 9, 20261 min readpart 06/13

React 18+ can prepare multiple UI versions simultaneously and interrupt low-priority work for urgent updates.

The Lane Model

A 31-bit bitmask where each bit is a priority level. Lanes replaced expiration times because bitmasks let React group updates (OR bits together), process subsets per render, and skip irrelevant work with a bitwise AND.

codetsx
const SyncLane          = 0b0000000000000000000000000000010;  // Discrete events
const InputContinuousLane = 0b0000000000000000000000000001000;  // Drag, scroll
const DefaultLane       = 0b0000000000000000000000000100000;  // Normal updates
const TransitionLane1   = 0b0000000000000000000001000000000;  // startTransition
const IdleLane          = 0b0100000000000000000000000000000;  // Lowest

startTransition

Wrapping a state update in startTransition assigns it a Transition Lane. If a high-priority update arrives (like keyboard input), React interrupts the transition, handles the urgent update, and restarts later.

Time Slicing

React's scheduler divides work into ~5ms chunks and yields back to the browser between them via MessageChannel (not requestIdleCallback, which is too unpredictable). This keeps animations smooth and inputs responsive.

Suspense

When a component throws a Promise, React catches it, renders the nearest <Suspense> fallback, attaches a .then() to the Promise, and retries when it resolves. In concurrent mode, it can keep showing old UI during transitions instead of flashing spinners.

Further reading