Skip to content

Commit cad3c02

Browse files
acdliteUmeshmalik
authored andcommitted
Add back temporary experimental_ aliases for Server Actions APIs (facebook#27461)
This adds back the `experimental_`-prefixed Server Actions APIs to the experimental builds only, so that apps that use those don't immediately break when upgrading. The APIs will log a warning to encourage people to move to the unprefixed version, or to switch to the canary release channel. We can remove these in a few weeks after we've given people a chance to upgrade. This does not affect the canary builds at all, since they never had the prefixed versions to begin with.
1 parent 44d40a0 commit cad3c02

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

packages/react-dom/index.experimental.js

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

packages/react/index.experimental.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,18 @@ export {
5858
useTransition,
5959
version,
6060
} from './src/React';
61+
62+
import {useOptimistic} from './src/React';
63+
64+
export function experimental_useOptimistic<S, A>(
65+
passthrough: S,
66+
reducer: ?(S, A) => S,
67+
): [S, (A) => void] {
68+
if (__DEV__) {
69+
console.error(
70+
'useOptimistic is now in canary. Remove the experimental_ prefix. ' +
71+
'The prefixed alias will be removed in an upcoming release.',
72+
);
73+
}
74+
return useOptimistic(passthrough, reducer);
75+
}

0 commit comments

Comments
 (0)