← Back to React, page 4

react-0080 · Medium mid

How does useTransition work in React 19, including async transitions, and what are its limits?

useTransition returns [isPending, startTransition]. State updates inside startTransition are marked non-urgent: React can interrupt them for urgent updates such as typing, and keeps showing the old UI while the new one renders. In React 19 the function may be async, so isPending stays true during awaited work. State updates after an await must be wrapped in another startTransition. Transitions cannot control text inputs and do not make slow code faster.

Full answer

React 18 introduced transitions. const [isPending, startTransition] = useTransition() gives a flag and a function. Updates inside startTransition(() => setTab('reports')) are low priority: if something urgent happens, such as a keystroke, React handles that first and can restart or drop the transition render. While the transition renders, the current UI stays on screen, and Suspense does not replace it with a fallback if the content is already visible. isPending lets you show a subtle indicator.

React 19 added async functions: startTransition(async () => { ... }). React keeps isPending true until the promise settles, which covers loading and saving. This is the foundation for Actions: forms, useActionState and useOptimistic work on top of it.

The limit to remember: React tracks transition updates only until the first await. A state update after an await runs outside the transition unless you wrap it again with startTransition. Write await load(); startTransition(() => setTab(next));. This is a known limitation of the current implementation. Errors thrown in the function propagate to the nearest error boundary.

What transitions are not: they do not debounce, they do not make slow components faster, and they do not work for controlled input values, because those must update synchronously or the text jumps. For the latter, use the same transition on a derived state, or useDeferredValue for a value you receive. A transition helps when an update causes heavy rendering. The long task is still there, but React yields between units of work so the input stays responsive.

The standalone startTransition import works outside components, but gives no isPending.

The example switches tabs after a simulated data load.

jsx
import { useState, useTransition } from 'react';

const loadReport = () => new Promise((resolve) => setTimeout(resolve, 50));

export default function Tabs() {
  const [tab, setTab] = useState('Overview');
  const [isPending, startTransition] = useTransition();

  function select(next) {
    startTransition(async () => {
      await loadReport();
      startTransition(() => setTab(next));
    });
  }

  return (
    <div>
      <button onClick={() => select('Overview')}>Overview</button>
      <button onClick={() => select('Reports')}>Reports</button>
      <p>
        Tab: {tab} {isPending ? '(loading)' : ''}
      </p>
    </div>
  );
}

The check pressed Reports and read the text right away, and again after the simulated load. Output of the run: start: OverviewReportsTab: Overview right after the click: OverviewReportsTab: Overview (loading) after the data arrived: OverviewReportsTab: Reports

Key points

  • Transition updates are non-urgent, interruptible and keep the old UI visible.
  • isPending shows that a transition is in progress.
  • In React 19 async functions are supported and isPending stays true until they finish.
  • Updates after an await need another startTransition.
  • Transitions do not speed up slow code and are not for controlled input values.

Common mistakes

  • Setting state after an await without wrapping it in startTransition.
  • Using a transition for the text of a controlled input.
  • Expecting a transition to make a slow render faster.
  • Reading isPending as a loading state for a Suspense fallback.
  • Calling startTransition and then also showing a separate manual loading flag.

Follow-ups

  • What is the difference between useTransition and useDeferredValue?
  • How do transitions interact with Suspense boundaries?
  • How do Actions in React 19 build on transitions?

Tips

  • Mention the await limitation. It separates people who used the API from people who read about it.
  • Say transitions are scheduling, not performance magic.
  • Connect transitions to Actions and forms.