@samitouri / QOS-React-1 / commits / 546178f910

`react-dom/server-rendering-stub`: restore experimental prefix for `useFormState` and `useFormStatus` (#27470)

in #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.

Josh Story committed Oct 5, 2023 at 08:53 UTC 546178f9109424f6a0176ea8702a7620c4417569
1 file changed +27
packages/react-dom/server-rendering-stub.js
+27
@@ -28,3 +28,30 @@ export {
28 useFormState,
29 unstable_batchedUpdates,
30 } 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 +}