Skip to content

Commit

Permalink
Add back temporary experimental_ aliases for Server Actions APIs (f…
Browse files Browse the repository at this point in the history
…acebook#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.
  • Loading branch information
acdlite authored and Umeshmalik committed Oct 8, 2023
1 parent 44d40a0 commit cad3c02
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/react-dom/index.experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,30 @@ export {
preinitModule,
version,
} from './src/client/ReactDOM';

import type {FormStatus} from 'react-dom-bindings/src/shared/ReactDOMFormActions';
import {useFormStatus, useFormState} from './src/client/ReactDOM';

export function experimental_useFormStatus(): FormStatus {
if (__DEV__) {
console.error(
'useFormStatus is now in canary. Remove the experimental_ prefix. ' +
'The prefixed alias will be removed in an upcoming release.',
);
}
return useFormStatus();
}

export function experimental_useFormState<S, P>(
action: (S, P) => Promise<S>,
initialState: S,
permalink?: string,
): [S, (P) => void] {
if (__DEV__) {
console.error(
'useFormState is now in canary. Remove the experimental_ prefix. ' +
'The prefixed alias will be removed in an upcoming release.',
);
}
return useFormState(action, initialState, permalink);
}
15 changes: 15 additions & 0 deletions packages/react/index.experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,18 @@ export {
useTransition,
version,
} from './src/React';

import {useOptimistic} from './src/React';

export function experimental_useOptimistic<S, A>(
passthrough: S,
reducer: ?(S, A) => S,
): [S, (A) => void] {
if (__DEV__) {
console.error(
'useOptimistic is now in canary. Remove the experimental_ prefix. ' +
'The prefixed alias will be removed in an upcoming release.',
);
}
return useOptimistic(passthrough, reducer);
}

0 comments on commit cad3c02

Please sign in to comment.