Skip to content

Commit

Permalink
Upgrade Server Actions to canary (facebook#27459)
Browse files Browse the repository at this point in the history
Upgrades the stability of Server Actions from experimental to canary.

- Turns on enableAsyncActions and enableFormActions
- Removes "experimental_" prefix from useOptimistic, useFormStatus, and
useFormState
  • Loading branch information
acdlite authored and alunyov committed Oct 11, 2023
1 parent 8f95706 commit 22236a4
Show file tree
Hide file tree
Showing 28 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion fixtures/flight-esm/src/Button.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import * as React from 'react';
import {experimental_useFormStatus as useFormStatus} from 'react-dom';
import {useFormStatus} from 'react-dom';
import ErrorBoundary from './ErrorBoundary.js';

const h = React.createElement;
Expand Down
2 changes: 1 addition & 1 deletion fixtures/flight-esm/src/Form.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import * as React from 'react';
import {experimental_useFormStatus as useFormStatus} from 'react-dom';
import {useFormStatus} from 'react-dom';
import ErrorBoundary from './ErrorBoundary.js';

const h = React.createElement;
Expand Down
2 changes: 1 addition & 1 deletion fixtures/flight/src/Button.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import * as React from 'react';
import {experimental_useFormStatus as useFormStatus} from 'react-dom';
import {useFormStatus} from 'react-dom';
import ErrorBoundary from './ErrorBoundary.js';

function ButtonDisabledWhilePending({action, children}) {
Expand Down
2 changes: 1 addition & 1 deletion fixtures/flight/src/Counter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import * as React from 'react';
import {experimental_useFormState as useFormState} from 'react-dom';
import {useFormState} from 'react-dom';

import Container from './Container.js';

Expand Down
2 changes: 1 addition & 1 deletion fixtures/flight/src/Form.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import * as React from 'react';
import {experimental_useFormStatus as useFormStatus} from 'react-dom';
import {useFormStatus} from 'react-dom';
import ErrorBoundary from './ErrorBoundary.js';

function Status() {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/index.classic.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export {
unstable_createEventHandle,
unstable_renderSubtreeIntoContainer,
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
useFormStatus as experimental_useFormStatus,
useFormState as experimental_useFormState,
useFormStatus,
useFormState,
prefetchDNS,
preconnect,
preload,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/index.experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export {
unstable_batchedUpdates,
unstable_renderSubtreeIntoContainer,
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
useFormStatus as experimental_useFormStatus,
useFormState as experimental_useFormState,
useFormStatus,
useFormState,
prefetchDNS,
preconnect,
preload,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export {
unstable_createEventHandle,
unstable_renderSubtreeIntoContainer,
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
useFormStatus as experimental_useFormStatus,
useFormState as experimental_useFormState,
useFormStatus,
useFormState,
prefetchDNS,
preconnect,
preload,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/index.modern.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export {
unstable_batchedUpdates,
unstable_createEventHandle,
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
useFormStatus as experimental_useFormStatus,
useFormState as experimental_useFormState,
useFormStatus,
useFormState,
prefetchDNS,
preconnect,
preload,
Expand Down
2 changes: 2 additions & 0 deletions packages/react-dom/index.stable.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export {
unmountComponentAtNode,
unstable_batchedUpdates,
unstable_renderSubtreeIntoContainer,
useFormStatus,
useFormState,
prefetchDNS,
preconnect,
preload,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/server-rendering-stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export {
preloadModule,
preinit,
preinitModule,
experimental_useFormStatus,
experimental_useFormState,
useFormStatus,
useFormState,
unstable_batchedUpdates,
} from './src/server/ReactDOMServerRenderingStub';
6 changes: 3 additions & 3 deletions packages/react-dom/src/__tests__/ReactDOMFizzForm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ describe('ReactDOMFizzForm', () => {
React = require('react');
ReactDOMServer = require('react-dom/server.browser');
ReactDOMClient = require('react-dom/client');
useFormStatus = require('react-dom').experimental_useFormStatus;
useFormState = require('react-dom').experimental_useFormState;
useOptimistic = require('react').experimental_useOptimistic;
useFormStatus = require('react-dom').useFormStatus;
useFormState = require('react-dom').useFormState;
useOptimistic = require('react').useOptimistic;
act = require('internal-test-utils').act;
container = document.createElement('div');
document.body.appendChild(container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('ReactDOMFizzServer', () => {
if (gate(flags => flags.enableSuspenseList)) {
SuspenseList = React.unstable_SuspenseList;
}
useFormState = ReactDOM.experimental_useFormState;
useFormState = ReactDOM.useFormState;

PropTypes = require('prop-types');

Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/__tests__/ReactDOMForm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ describe('ReactDOMForm', () => {
useState = React.useState;
Suspense = React.Suspense;
startTransition = React.startTransition;
useFormStatus = ReactDOM.experimental_useFormStatus;
useFormState = ReactDOM.experimental_useFormState;
useFormStatus = ReactDOM.useFormStatus;
useFormState = ReactDOM.useFormState;
container = document.createElement('div');
document.body.appendChild(container);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ describe('react-dom-server-rendering-stub', () => {

// @gate enableFormActions
// @gate enableAsyncActions
it('exports experimental_useFormStatus', async () => {
it('exports useFormStatus', async () => {
function App() {
const {pending} = ReactDOM.experimental_useFormStatus();
const {pending} = ReactDOM.useFormStatus();
return 'Pending: ' + pending;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactDOMServerRenderingStub.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export {
prefetchDNS,
} from '../shared/ReactDOMFloat';
export {
useFormStatus as experimental_useFormStatus,
useFormState as experimental_useFormState,
useFormStatus,
useFormState,
} from 'react-dom-bindings/src/shared/ReactDOMFormActions';

export function createPortal() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('ReactAsyncActions', () => {
assertLog = require('internal-test-utils').assertLog;
useTransition = React.useTransition;
useState = React.useState;
useOptimistic = React.experimental_useOptimistic;
useOptimistic = React.useOptimistic;

textCache = new Map();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('ReactFlightDOMForm', () => {
ReactDOMServer = require('react-dom/server.edge');
ReactDOMClient = require('react-dom/client');
act = require('react-dom/test-utils').act;
useFormState = require('react-dom').experimental_useFormState;
useFormState = require('react-dom').useFormState;
container = document.createElement('div');
document.body.appendChild(container);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.classic.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export {
useLayoutEffect,
useInsertionEffect,
useMemo,
experimental_useOptimistic,
useOptimistic,
useReducer,
useRef,
useState,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export {
useInsertionEffect,
useLayoutEffect,
useMemo,
experimental_useOptimistic,
useOptimistic,
useReducer,
useRef,
useState,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export {
useInsertionEffect,
useLayoutEffect,
useMemo,
experimental_useOptimistic,
useOptimistic,
useSyncExternalStore,
useReducer,
useRef,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/index.modern.fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export {
useInsertionEffect,
useLayoutEffect,
useMemo,
experimental_useOptimistic,
useOptimistic,
useReducer,
useRef,
useState,
Expand Down
1 change: 1 addition & 0 deletions packages/react/index.stable.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export {
useLayoutEffect,
useMemo,
useReducer,
useOptimistic,
useRef,
useState,
useSyncExternalStore,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export {
useInsertionEffect,
useLayoutEffect,
useMemo,
useOptimistic as experimental_useOptimistic,
useOptimistic,
useSyncExternalStore,
useReducer,
useRef,
Expand Down
6 changes: 2 additions & 4 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export const enableComponentStackLocations = true;

// TODO: Finish rolling out in www
export const enableClientRenderFallbackOnTextMismatch = true;
export const enableFormActions = true;
export const enableAsyncActions = true;

// Not sure if www still uses this. We don't have a replacement but whatever we
// replace it with will likely be different than what's already there, so we
Expand Down Expand Up @@ -82,8 +84,6 @@ export const enableLegacyCache = __EXPERIMENTAL__;
export const enableCacheElement = __EXPERIMENTAL__;
export const enableFetchInstrumentation = true;

export const enableFormActions = __EXPERIMENTAL__;

export const enableBinaryFlight = __EXPERIMENTAL__;

export const enableTaint = __EXPERIMENTAL__;
Expand Down Expand Up @@ -120,8 +120,6 @@ export const enableUseEffectEventHook = __EXPERIMENTAL__;
// (handled with an MutationObserver) instead of inline-scripts
export const enableFizzExternalRuntime = true;

export const enableAsyncActions = __EXPERIMENTAL__;

export const alwaysThrottleRetries = true;

export const useMicrotasksForSchedulingInFabric = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
export const enableFizzExternalRuntime = false;
export const enableDeferRootSchedulingToMicrotask = true;

export const enableAsyncActions = false;
export const enableAsyncActions = true;

export const alwaysThrottleRetries = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const useModernStrictMode = false;
export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
export const enableDeferRootSchedulingToMicrotask = true;

export const enableAsyncActions = false;
export const enableAsyncActions = true;

export const alwaysThrottleRetries = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const enableDO_NOT_USE_disableStrictPassiveEffect = false;
export const enableFizzExternalRuntime = false;
export const enableDeferRootSchedulingToMicrotask = true;

export const enableAsyncActions = false;
export const enableAsyncActions = true;

export const alwaysThrottleRetries = true;

Expand Down

0 comments on commit 22236a4

Please sign in to comment.