mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Add back temporary experimental_ aliases for Server Actions APIs (#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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user