Skip to content

Commit b65afdd

Browse files
authored
Clarify useActionState async non-transition warning (facebook#32207)
facebook#28491 (comment)
1 parent de1eaa2 commit b65afdd

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/react-dom/src/__tests__/ReactDOMForm-test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,9 +1494,10 @@ describe('ReactDOMForm', () => {
14941494
await act(() => dispatch());
14951495
assertConsoleErrorDev([
14961496
[
1497-
'An async function was passed to useActionState, but it was dispatched outside of an action context. ' +
1498-
'This is likely not what you intended. ' +
1499-
'Either pass the dispatch function to an `action` prop, or dispatch manually inside `startTransition`',
1497+
'An async function with useActionState was called outside of a transition. ' +
1498+
'This is likely not what you intended (for example, isPending will not update ' +
1499+
'correctly). Either call the returned function inside startTransition, or pass it ' +
1500+
'to an `action` or `formAction` prop.',
15001501
{withoutStack: true},
15011502
],
15021503
]);

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,10 +2231,10 @@ function handleActionReturnValue<S, P>(
22312231
if (__DEV__) {
22322232
if (!node.isTransition) {
22332233
console.error(
2234-
'An async function was passed to useActionState, but it was ' +
2235-
'dispatched outside of an action context. This is likely not ' +
2236-
'what you intended. Either pass the dispatch function to an ' +
2237-
'`action` prop, or dispatch manually inside `startTransition`',
2234+
'An async function with useActionState was called outside of a transition. ' +
2235+
'This is likely not what you intended (for example, isPending will not update ' +
2236+
'correctly). Either call the returned function inside startTransition, or pass it ' +
2237+
'to an `action` or `formAction` prop.',
22382238
);
22392239
}
22402240
}

0 commit comments

Comments
 (0)