Concurrent rendering and transitions
React 18's concurrent model: renders are now interruptible and can be thrown away, and startTransition marks an update as non-urgent.
Concurrent rendering and transitions
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Before React 18, rendering was synchronous: once React started rendering an update, it ran to completion on the main thread and could not be stopped, even if a more urgent update arrived in the meantime.
- React 18 introduced concurrent rendering: React can start rendering an update, pause partway through, and either resume it later or throw the in-progress work away entirely and restart with newer information.
- 'Concurrent' describes React's internal ability to work on more than one version of the UI without committing either, not a change to when your component functions run or what they return.
- startTransition is the entry point for telling React an update is non-urgent: wrap a state update in it, and React renders that update at lower priority, letting an urgent update (like a keystroke) interrupt and go first.
- Marking an update as a transition doesn't make it finish faster; it changes the order React is willing to work on things in, so the UI stays responsive to the input the user is actively producing.
- Concurrent features are opt-in per update. Code that calls no concurrent APIs renders exactly the way it did under React 17's synchronous model.
Rendering used to be all-or-nothing
Through React 17, rendering was synchronous in a very literal sense: once React began walking the component tree to compute an update, it ran that computation to completion, on the main thread, before doing anything else. If the update touched a large tree, the browser could not process a keystroke, a scroll, or a click until React finished — the render blocked everything.
This was fine for small updates. It became visible as jank on anything expensive: typing into a search box that re-renders a 10,000-row list on every keystroke, for example, would visibly lag, because React had no way to set the list re-render aside and handle the keystroke first. Whatever update started first finished first, no matter how urgent something newer turned out to be.
What “concurrent” actually changes
React 18’s concurrent renderer gives React a new capability: it can start computing a render, pause in the middle, and either come back to it or throw it away and start over — without ever showing the user the half-finished result. Two things are important about what this is not:
- It does not mean multiple renders execute literally in parallel on multiple threads. JavaScript is still single-threaded; React is still doing one thing at a time. “Concurrent” here means React can interleave and reorder the work, not that it runs simultaneously.
- It does not change when your component function runs or what it’s allowed to do. Your render logic still needs to be pure for exactly this reason — React may call it, throw the result away without committing it, and call it again, so a render with side effects would run those side effects more than once for no reason.
What actually changes is scheduling. React now tracks a priority for each pending update. A low-priority update can be paused to let a high-priority one — like the text in an input the user is actively typing into — render and commit first. Once the high-priority work is done, React resumes or restarts the low-priority render with whatever the latest state is by then.
startTransition: marking an update as non-urgent
startTransition is the API that lets you tell React which updates fall into that low-priority category.
import { useState, startTransition } from "react";
function SearchBox({ allItems }) {
const [query, setQuery] = useState("");
const [results, setResults] = useState(allItems);
function handleChange(e) {
const value = e.target.value;
setQuery(value); // urgent: keep the input responsive
startTransition(() => {
// non-urgent: can be interrupted by the next keystroke
setResults(filterItems(allItems, value));
});
}
return (
<>
<input value={query} onChange={handleChange} />
<ResultsList items={results} />
</>
);
}
setQuery updates immediately and stays urgent, so the character the user just typed appears in the input without delay. setResults is wrapped in startTransition, so if filterItems is expensive enough to take a noticeable amount of time on a large list, React is free to interrupt that filtering render the moment another keystroke arrives, rather than finishing a filter pass that’s already stale before it starts rendering the next one.
Without the transition, both setQuery and setResults would be part of the same render, and a slow filter would drag the input along with it — the classic symptom of synchronous rendering on an expensive update. With it, the input and the results list are allowed to update at different speeds, and the user only ever feels the fast one.
startTransition also interacts with Suspense: if the update inside a transition causes a component to suspend, React keeps showing the current UI (rather than flashing the Suspense fallback) while the transition’s work happens in the background, only swapping to the new UI once it’s ready.
What startTransition is not for
Transitions are for deprioritizing rendering work, not for delaying a side effect, a network request, or anything that needs to happen in a specific order. It only changes when React commits a state update to the screen relative to other updates — it has no effect on code outside of triggering a re-render.
What the video covers
ui.dev’s lesson, drawn from Tyler McGinnis’s react.gg course, tells concurrent rendering as a narrative: why React’s synchronous model became a real problem at scale, what React 18 changed about renders being interruptible and discardable, and how that groundwork made startTransition possible. It’s framed as motivation and mental model rather than a line-by-line API walkthrough, which is exactly the gap this lesson’s worked example fills — watch it for the “why now” story, then use the code above for the hands-on API.
Where this fits
startTransition is the building block; the next lesson covers the two hooks built on top of it for everyday use: useTransition and useDeferredValue.
Check yourself
Under React 17's rendering model, what happened if a high-priority update (like a keypress) arrived while React was in the middle of rendering a different update?
Nothing could interrupt it. React 17 rendered synchronously: once it started walking the tree for an update, it ran straight through to completion and committed the result before handling anything else, even an update the user cares about more, like the character they just typed.
What does it mean for a render to be 'interruptible' in React 18's concurrent model?
React can pause partway through rendering an update, hand control back to the browser so it can handle more urgent work like user input, and either pick the paused render back up or discard it and start over with newer data — rather than being locked into finishing one render before doing anything else.
Does wrapping a state update in startTransition make that update's rendering happen faster?
No. startTransition does not speed up any individual render; it changes its priority. React is now willing to interrupt that render if something more urgent comes in, and may delay starting it until urgent work is handled, which keeps the whole app feeling responsive even though the transitioned update itself may take just as long or longer.
If a component never calls startTransition or any other concurrent API, does concurrent rendering change how it behaves?
No. Concurrent features are opt-in on a per-update basis. A component that only ever triggers ordinary, unmarked updates renders the same way it would have under React 17's synchronous model; React 18 only changes behavior for updates you explicitly mark as non-urgent or that suspend.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.