Skip to content

Commit 08a46a3

Browse files
gnoffalunyov
authored andcommitted
react-dom/server-rendering-stub: restore experimental prefix for useFormState and useFormStatus (facebook#27470)
in facebook#27461 the experimental prefix was added back for `useFormState` and `useFormStatus` in react-dom. However these functions are also exported from the server rendering stub too and when using the stub with experimental prefixes their absence causes unexpected errors. This change adds back the experimental prefix for these two hooks to match the experimental build of react-dom.
1 parent 8a08682 commit 08a46a3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

packages/react-dom/server-rendering-stub.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,30 @@ export {
2828
useFormState,
2929
unstable_batchedUpdates,
3030
} from './src/server/ReactDOMServerRenderingStub';
31+
32+
import type {FormStatus} from 'react-dom-bindings/src/shared/ReactDOMFormActions';
33+
import {useFormStatus, useFormState} from './src/client/ReactDOM';
34+
35+
export function experimental_useFormStatus(): FormStatus {
36+
if (__DEV__) {
37+
console.error(
38+
'useFormStatus is now in canary. Remove the experimental_ prefix. ' +
39+
'The prefixed alias will be removed in an upcoming release.',
40+
);
41+
}
42+
return useFormStatus();
43+
}
44+
45+
export function experimental_useFormState<S, P>(
46+
action: (S, P) => Promise<S>,
47+
initialState: S,
48+
permalink?: string,
49+
): [S, (P) => void] {
50+
if (__DEV__) {
51+
console.error(
52+
'useFormState is now in canary. Remove the experimental_ prefix. ' +
53+
'The prefixed alias will be removed in an upcoming release.',
54+
);
55+
}
56+
return useFormState(action, initialState, permalink);
57+
}

0 commit comments

Comments
 (0)