React Reference ยท Concepts and Pitfalls
Concurrent rendering
Understand React concurrent rendering: interruptible renders, urgent versus transition updates, useTransition, useDeferredValue and what stays synchronous.
Concurrent rendering means React can start rendering an update, pause, work on something more urgent, and later resume or throw the unfinished work away. Before React 18, once a render began it ran to the end and blocked the browser. Now a render that is marked as non-urgent can be interrupted, so typing, clicking and scrolling stay responsive while a heavy tree is prepared in the background.
Concurrent rendering is not a mode you switch on, and it does not mean multi-threading. JavaScript still runs on one thread. React simply splits rendering into small units of work and checks between them whether something more important arrived. You opt into the behavior per update with useTransition, startTransition or useDeferredValue. Everything is built on createRoot (see createRoot).
const [isPending, startTransition] = useTransition(); startTransition(() => { setTab('reports'); // low priority: may be interrupted });
Try it
Open the console and type. Each key press first renders Preview with the old deferred text (the urgent render, so the input responds), then renders it again with the new text in the background. If the preview were heavy and you typed quickly, React would abandon the background render for an outdated value and log only the values it had time to finish.
Urgent updates and transitions
React sorts updates into lanes of priority. Two groups matter for you:
- Urgent updates reflect direct interaction: typing, clicking, pressing. They must feel immediate, so React renders them first and without interruption.
- Transition updates move the UI from one view to another: switching a tab, applying a filter, navigating. They may take a moment, and showing the old screen a little longer is acceptable.
When you wrap a state update in a transition, React renders the new state in the background. If an urgent update arrives meanwhile, React pauses the transition, handles the urgent one, and then restarts the transition from the latest state. Intermediate transition renders are discarded. The user never sees half-finished work: the screen switches only when the transition render is complete.
What a transition can and cannot do
- A transition keeps the currently shown UI instead of replacing it with a
Suspensefallback, when the content that suspends is already visible. isPendingistruefrom the moment the transition starts until its result is committed, so you can dim content or show a spinner.- The state updates inside the callback must run synchronously when the callback is called. In React 19 you can pass an async function (an Action) and React tracks the pending state across the
await, but state updates made after anawaitmust be wrapped in anotherstartTransitioncall to be marked as transitions. - A transition cannot control text inputs. Use the urgent state for
value(as in the first example) and the transition state for the expensive consumer.
Usage notes
- Transitions do not make rendering faster. They make the app more responsive by letting urgent work win. A rendering bottleneck still costs the same CPU time; consider
memoor splitting work if you also need speed. - Render functions must be pure. A render may start and be thrown away many times, so side effects in render (writes, network calls, mutating outside values) will run more often or at odd times. See Pure components.
useDeferredValueversususeTransition: use the hook when you receive a value and cannot wrap the code that sets it (for example, a prop); use the transition when you own thesetcall.- Debouncing is a different tool. A debounce waits a fixed time before doing anything; a transition starts immediately and adapts to the device speed.
- Tearing: external mutable stores can show two values in one frame during an interruptible render.
useSyncExternalStoreforces consistent, synchronous reads. - Effects run after commit, never during a discarded render, so cleanup logic stays predictable.
- Strict Mode double-renders in development to help you notice impure code.