awesome-everything RU
↑ Back to the climb

Browser & Frontend Runtime

Priority lanes, time-slicing, and useTransition

Crux React 18 assigns every update a lane (priority bucket). Time-slicing breaks render work into 5 ms slices. useTransition and useDeferredValue put expensive updates in the transition lane so keystrokes can interrupt them.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at middle altitude — in the sky
◷ 14 min

You wrap a slow list filter in startTransition. Typing stays instant, the list catches up when React has spare time, and a spinner signals the wait. Without it, every keystroke triggers a 50 ms blocking render. The mechanism that makes this work is React’s priority lane system.

Priority lanes. React 18 assigns every update a lane — a priority bucket. The lane model (a bitmask of 31 lanes) lets React work on high-priority updates first and defer low-priority ones. The important tiers:

  • Sync / discrete: A click, a keypress. React renders it immediately and blocking, because the user is waiting on that exact interaction.
  • Default: Ordinary state updates with no transition wrapper.
  • Transition: Set via useTransition or useDeferredValue. Used for updates the user is not directly waiting on — filtering a big list, navigating to a new view. These can be interrupted by anything more urgent.
  • Idle: The lowest. Background work the app can do whenever the main thread is free.

When a keypress arrives mid-transition-render, React abandons the in-progress transition render, processes the keypress at high priority, and restarts the transition afterward.

Lane priority tiers
sync / clickRenders immediately, blocking — user is waiting
defaultNormal setState — scheduled soon, not blocking
transitionstartTransition / useDeferredValue — interruptible, time-sliced
idleLowest — runs only when nothing else is pending

Time-slicing: how the render phase yields. A long synchronous render blocks input — the exact failure mode the event-loop piece described. React’s scheduler breaks the render phase into slices. After about 5 ms of reconciliation work, the scheduler checks shouldYield(); if true, it stops, posts a continuation task via MessageChannel (the cross-browser way to schedule a task with no clamping), and lets the browser run input handlers and rendering. The continuation task resumes the render from the stored fiber pointer.

A 50 ms render becomes ten 5 ms slices interleaved with the browser’s own work, and input stays responsive throughout. This only applies to concurrent renders — transitions and other non-urgent updates. A synchronous-priority update (discrete input) still renders in one blocking pass, because making the user wait for a yield would defeat the purpose.

The lane bitmask. A lane is one bit in a 31-bit integer. Representing priority as a bitmask lets React do set operations in single CPU instructions: “are there any high-priority lanes pending?” is a mask-and-test; “render all lanes at or above this priority” is a bitmask comparison. Updates in compatible lanes are batched — multiple setState calls in one event handler (or, since React 18, across promises and timeouts via automatic batching) collapse into a single render. This is why you cannot read the new state synchronously right after setState: the render that applies it has not happened yet.

useTransition and useDeferredValue. These are the two hooks that put work into the transition lane. useTransition gives you a startTransition function — state updates inside it are marked low-priority and interruptible, plus an isPending flag for showing a spinner. The canonical use: a search input where the input value itself updates synchronously (so typing feels instant) but the expensive filtered-list update is wrapped in startTransition (so it yields to further keystrokes).

useDeferredValue is the same idea from the consuming side: it gives you a copy of a value that “lags behind” — React updates it at transition priority, so a component reading the deferred value re-renders only when React has spare time. Use useTransition when you own the state update; useDeferredValue when the value comes from props or context you do not control.

Keep an expensive filtered list from blocking the input

1/3
Complete the analogy

React 18 assigns every update a priority bucket so it can render urgent work first and defer the rest. A keypress goes in the synchronous bucket; a big list filter wrapped in startTransition goes in a low, interruptible bucket. What does React call these priority buckets?

Quiz

You wrap an expensive list update in `startTransition`. A keystroke arrives while that render is in progress. What does React do?

Quiz

Which kind of update does React render in one blocking pass, with no time-slicing?

Compute it

React's scheduler does about 5 ms of render work per slice. The frame budget at 60 fps is 16.67 ms. Roughly how many React render slices can fit in one frame alongside ~6 ms of browser overhead?

slices
Recall before you leave
  1. 01
    Why does a click event render synchronously and blocking, while a startTransition update does not?
  2. 02
    How does React yield to the browser between render slices?
  3. 03
    What is the difference between useTransition and useDeferredValue?
Recap

React 18’s lane system assigns each update a priority bucket. Discrete input (clicks, keystrokes) renders in the sync lane — one blocking pass, no yield. Ordinary state updates use the default lane. Work wrapped in startTransition or read via useDeferredValue runs in the transition lane — interruptible and time-sliced. The scheduler breaks transition renders into ~5 ms slices, posts a continuation via MessageChannel between slices, and resumes from the stored fiber pointer. This is why a 50 ms list render does not drop frames: it becomes ten 5 ms slices interleaved with browser repaints and input handling. When a keystroke arrives mid-transition, React abandons the in-progress render, handles the keystroke at sync priority, and restarts the transition from scratch.

Connected lessons
appears again in143
Continue the climb ↑Bailout, memoisation, and tearing
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources4
expand
  1. 01
  2. 02
  3. 03
  4. 04

Trademarks belong to their respective owners. Editorial reference only.