@samitouri / QOS-React / commits / b65afdd0c1

Clarify useActionState async non-transition warning (#32207)

https://github.com/facebook/react/pull/28491#issuecomment-2094861155

Sophie Alpert committed Jan 24, 2025 at 09:25 UTC b65afdd0c1f644f3630c4e8cfd9ac264c5ac329f
2 files changed +8 -7
packages/react-dom/src/__tests__/ReactDOMForm-test.js
+4 -3
@@ -1494,9 +1494,10 @@ describe('ReactDOMForm', () => {
1494 await act(() => dispatch());
1495 assertConsoleErrorDev([
1496 [
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.',
1501 {withoutStack: true},
1502 ],
1503 ]);
packages/react-reconciler/src/ReactFiberHooks.js
+4 -4
@@ -2231,10 +2231,10 @@ function handleActionReturnValue<S, P>(
2231 if (__DEV__) {
2232 if (!node.isTransition) {
2233 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.',
2238 );
2239 }
2240 }