ReactMedium

What is a transition update?

A transition update is a state update marked as non-urgent with startTransition (or useTransition). React renders it in the background, lets urgent updates interrupt it, avoids replacing visible content with Suspense fallbacks, and exposes isPending while it is in progress. In React 19, transitions can be async functions called Actions.

Urgent vs transition

  • Urgent: typing, clicking, pressing. Users expect an instant response.
  • Transition: moving between views, filtering results, loading the next page. A short delay is acceptable as long as input stays responsive.

Behavior

  • If a newer transition starts, React can abandon the old one.
  • Suspended components inside a transition keep showing the previous UI instead of a fallback.
  • isPending is true until the transition finishes.
  • React 19 Actions: startTransition(async () => { await save(); setData(x); }) keeps isPending true for the whole async function; errors go to the nearest error boundary. useActionState and <form action> use transitions automatically.
  • React 19.3: unrelated transitions render independently, so a slow one does not hold up a fast one.

Where you meet them

  • React Router and Next.js navigations are transitions.
  • useDeferredValue updates behave like transitions.
  • <ViewTransition> animations trigger for transitions, and addTransitionType labels them (for example "slide-forward").

Limits

  • Do not use transitions for controlled input values (the text would lag).
  • The callback must call the state update synchronously, or after an await with React 19's Action semantics.

Code example

tsx
1import { startTransition, useState, useTransition, addTransitionType, ViewTransition } from "react";
2
3export function Gallery({ photos }: { photos: string[] }) {
4 const [index, setIndex] = useState(0);
5 const [isPending, startNav] = useTransition();
6
7 function go(delta: number) {
8 startNav(() => {
9 addTransitionType(delta > 0 ? "forward" : "back"); // React 19.3: label the transition
10 setIndex((i) => (i + delta + photos.length) % photos.length);
11 });
12 }
13
14 return (
15 <div>
16 <ViewTransition key={index} enter={{ forward: "slide-in-right", back: "slide-in-left", default: "auto" }}>
17 <img src={photos[index]} alt={`Photo ${index + 1}`} width={480} />
18 </ViewTransition>
19 <button onClick={() => go(-1)}>Prev</button>
20 <button onClick={() => go(1)}>Next</button>
21 {isPending && <small> loading…</small>}
22 </div>
23 );
24}
25
26// Outside components (no isPending):
27export const preloadNext = (fn: () => void) => startTransition(fn);

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