How to Fix “An async function with useActionState was called outside of a transition” in React
In React, An async function with useActionState was called outside of a transition. appears when you call the function returned by useActionState directly, outside a Transition. Calling it inside a function passed to startTransition, or passing it as the action of a <form>, makes the error go away. This error tends to happen when a button such as "Add to cart" saves to a server and you want to show "Saving…" while the save is in progress. The official reference also lists it as a common mistake.
I triggered this error on purpose in a test environment and copied the message as shown. I then confirmed that after the fix, the error is gone and the pending state (isPending) appears.
The test environment is Ubuntu 24.04 with Node.js 22.23.5. I used a project created from the react-ts template of npm create vite@latest (react / react-dom 19.3.1, @types/react 19.3.3, Vite 8.4.0, TypeScript 7.0.2), and I wrapped the component in StrictMode. I opened the page and operated it with Chromium 158 driven by Playwright 1.63.0. I did not test the approach of passing the function to a button's formAction, nor frameworks such as Next.js, nor combinations with Server Functions.
- 1. The message you get when calling from an onClick handler
- 2. The pending state never appears
- 3. Fixing it by wrapping the call in startTransition
- 4. If you pass it to a form's action, no wrapping is needed
- 5. If the function is not async, calling it directly does not error
- 6. In the production build, the pending state just disappears with no message
The message you get when calling from an onClick handler
I prepared a button that increments the cart quantity by 1 on each press. Instead of saving to a server, it calls saveQuantity, which waits one second.
// Stand-in for saving to a server. Waits 1 second, then returns the saved quantity
export function saveQuantity(next: number): Promise<number> {
return new Promise((resolve) => setTimeout(() => resolve(next), 1000));
}
I passed the async function addToCart to useActionState and called the returned dispatch from a click handler.
import { useActionState } from 'react';
import { saveQuantity } from './api';
async function addToCart(prev: number): Promise<number> {
return await saveQuantity(prev + 1);
}
// Incorrect: dispatch is called directly in the click handler
export default function BadClick() {
const [quantity, dispatch, isPending] = useActionState(addToCart, 0);
return (
<button type="button" onClick={() => dispatch()}>
カートに追加({quantity}個){isPending ? ' 保存中…' : ''}
</button>
);
}
Neither the type check (npx tsc -p tsconfig.app.json --noEmit) nor oxlint, which comes with the template, reported any errors or warnings. I opened the page with the same development server that npm run dev (which runs vite) starts, and when I pressed the button, the DevTools console showed a red console.error line with this message:
An async function with useActionState was called outside of a transition. This is likely not what you intended (for example, isPending will not update correctly). Either call the returned function inside startTransition, or pass it to an `action` or `formAction` prop.
It means: an async function from useActionState was called outside a Transition. This is probably not what you intended (for example, isPending will not update correctly). Either call the returned function inside startTransition, or pass it to an action or formAction prop.

The explanation of this error on the same page shows the same message text.
The pending state never appears
The "isPending will not update correctly" part of the message did happen on screen. I recorded how many milliseconds after pressing the button the button text changed:
0ms "カートに追加(0個)" → 1005ms "カートに追加(1個)"
The quantity only changed to 1 when the save finished after one second. "Saving…" never appeared during that time. For one second after the press, the button gave no feedback at all.
Fixing it by wrapping the call in startTransition
I moved the dispatch call into a function passed to startTransition. startTransition is imported from react.
import { startTransition, useActionState } from 'react';
import { saveQuantity } from './api';
async function addToCart(prev: number): Promise<number> {
return await saveQuantity(prev + 1);
}
// Fixed: dispatch is called inside the function passed to startTransition
export default function GoodTransition() {
const [quantity, dispatch, isPending] = useActionState(addToCart, 0);
function handleClick() {
startTransition(() => {
dispatch();
});
}
return (
<button type="button" onClick={handleClick}>
カートに追加({quantity}個){isPending ? ' 保存中…' : ''}
</button>
);
}
Pressing the button produced no error. The only thing in the console was the React DevTools notice.

Right after the press, "Saving…" appeared on the button. When the save finished, the quantity became 1 and "Saving…" disappeared.
0ms "カートに追加(0個)" → 4ms "カートに追加(0個) 保存中…" → 1004ms "カートに追加(1個)"
The official reference's section on isPending not updating also says to wrap dispatch in startTransition when you call it yourself.
Wrapping the call in the startTransition returned by useTransition gave the same result. There was no error, and the text changed as 0ms "カートに追加(0個)" → 4ms "カートに追加(0個) 保存中…" → 1004ms "カートに追加(1個)".
If you pass it to a form's action, no wrapping is needed
If the button can be a submit button inside a <form>, you can also pass dispatch directly as the <form>'s action.
import { useActionState } from 'react';
import { saveQuantity } from './api';
async function addToCart(prev: number): Promise<number> {
return await saveQuantity(prev + 1);
}
// Fixed: dispatch is passed as the form's action
export default function GoodFormAction() {
const [quantity, dispatch, isPending] = useActionState(addToCart, 0);
return (
<form action={dispatch}>
<button type="submit">
カートに追加({quantity}個){isPending ? ' 保存中…' : ''}
</button>
</form>
);
}
I did not write startTransition, yet no error appeared, and the text changed as 0ms "カートに追加(0個)" → 5ms "カートに追加(0個) 保存中…" → 1007ms "カートに追加(1個)", the same as when I wrapped the call. According to the reference's explanation of passing the function to a form's action, React wraps the submission in a Transition automatically when you pass it this way. In this case, the second argument of addToCart receives the submitted FormData.
If the function is not async, calling it directly does not error
For comparison, I changed addToCart to a non-async function that returns prev + 1 directly, and called dispatch directly from the click handler. In this case no error appeared, and the quantity became 1 four milliseconds after the press.
Looking at the development code of react-dom 19.3.1, this message is only shown when the function's return value is a Promise (an object with then), and only if the call is outside a Transition. An async function always returns a Promise, so any async function you pass will always be subject to this check.
In the production build, the pending state just disappears with no message
I ran npm run build, opened the result with npx vite preview, and tried the incorrect BadClick. No error appeared in the console, but the button text went 0ms "カートに追加(0個)" → 1003ms "カートに追加(1個)", so "Saving…" never appeared, just as in the development server. The message string itself was not present in the production code of react-dom or in the built output.
In production, a button that gives no feedback for one second after a press just behaves that way, with no message at all. If you see this error during development, move the call to startTransition or to a <form>'s action right away.





