From 10dfca54edc265aebde1f95fc53c35cc5a5ff664 Mon Sep 17 00:00:00 2001 From: Noah Lemen Date: Thu, 6 Jul 2023 14:09:53 -0400 Subject: [PATCH] rename SuspenseList export to unstable_SuspenseList (#27061) ## Summary as we began [discussing yesterday](https://github.com/facebook/react/pull/27056#discussion_r1253282784), `SuspenseList` is not actually stable yet, and should likely be exported with the `unstable_` prefix. the conversation yesterday began discussing this in the context of the fb-specific packages, but changing it there without updating everywhere else leads to test failures, so here the change is made across packages. ## How did you test this change? ``` yarn flow dom-browser yarn test ``` --- fixtures/stacks/Example.js | 2 +- packages/react-devtools-shared/src/__tests__/store-test.js | 4 ++-- .../react-devtools-shell/src/app/SuspenseTree/index.js | 7 ++++++- .../react-dom/src/__tests__/ReactDOMFizzServer-test.js | 2 +- .../ReactDOMServerPartialHydration-test.internal.js | 2 +- .../src/__tests__/ReactDOMServerSuspense-test.internal.js | 2 +- .../src/__tests__/ReactWrongReturnPointer-test.js | 2 +- packages/react-is/src/__tests__/ReactIs-test.js | 2 +- .../src/__tests__/ReactContextPropagation-test.js | 2 +- .../src/__tests__/ReactHooksWithNoopRenderer-test.js | 2 +- .../src/__tests__/ReactSuspenseList-test.js | 2 +- .../src/__tests__/ReactSuspenseyCommitPhase-test.js | 2 +- packages/react/index.classic.fb.js | 3 +-- packages/react/index.experimental.js | 2 +- packages/react/index.js | 2 +- packages/react/index.modern.fb.js | 3 +-- packages/react/src/React.js | 2 +- packages/react/src/ReactSharedSubset.experimental.js | 2 +- 18 files changed, 24 insertions(+), 21 deletions(-) diff --git a/fixtures/stacks/Example.js b/fixtures/stacks/Example.js index 3ea0ba14c489d..9a1b569b12e23 100644 --- a/fixtures/stacks/Example.js +++ b/fixtures/stacks/Example.js @@ -38,7 +38,7 @@ function Example() { DisplayName, null, x( - React.SuspenseList, + React.unstable_SuspenseList, null, x( NativeClass, diff --git a/packages/react-devtools-shared/src/__tests__/store-test.js b/packages/react-devtools-shared/src/__tests__/store-test.js index b6af0aaff2921..c277f6f167d06 100644 --- a/packages/react-devtools-shared/src/__tests__/store-test.js +++ b/packages/react-devtools-shared/src/__tests__/store-test.js @@ -693,13 +693,13 @@ describe('Store', () => { }; const Wrapper = ({shouldSuspense}) => ( - + }> {shouldSuspense ? : } - + ); diff --git a/packages/react-devtools-shell/src/app/SuspenseTree/index.js b/packages/react-devtools-shell/src/app/SuspenseTree/index.js index 88a56dc101631..846e3f8ef636e 100644 --- a/packages/react-devtools-shell/src/app/SuspenseTree/index.js +++ b/packages/react-devtools-shell/src/app/SuspenseTree/index.js @@ -8,7 +8,12 @@ */ import * as React from 'react'; -import {Fragment, Suspense, SuspenseList, useState} from 'react'; +import { + Fragment, + Suspense, + unstable_SuspenseList as SuspenseList, + useState, +} from 'react'; function SuspenseTree(): React.Node { return ( diff --git a/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js b/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js index 434924e86a039..42ed4c986ab69 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js @@ -81,7 +81,7 @@ describe('ReactDOMFizzServer', () => { Suspense = React.Suspense; use = React.use; if (gate(flags => flags.enableSuspenseList)) { - SuspenseList = React.SuspenseList; + SuspenseList = React.unstable_SuspenseList; } PropTypes = require('prop-types'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js index 4384bc03651bc..2468e6303a291 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js @@ -116,7 +116,7 @@ describe('ReactDOMServerPartialHydration', () => { Offscreen = React.unstable_Offscreen; useSyncExternalStore = React.useSyncExternalStore; if (gate(flags => flags.enableSuspenseList)) { - SuspenseList = React.SuspenseList; + SuspenseList = React.unstable_SuspenseList; } const InternalTestUtils = require('internal-test-utils'); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js index 8bf03548ce959..2a0e1f68a72b2 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js @@ -30,7 +30,7 @@ function initModules() { ReactTestUtils = require('react-dom/test-utils'); act = require('internal-test-utils').act; if (gate(flags => flags.enableSuspenseList)) { - SuspenseList = React.SuspenseList; + SuspenseList = React.unstable_SuspenseList; } // Make them available to the helpers. diff --git a/packages/react-dom/src/__tests__/ReactWrongReturnPointer-test.js b/packages/react-dom/src/__tests__/ReactWrongReturnPointer-test.js index 831c8a7d85784..468d5b54e1ae2 100644 --- a/packages/react-dom/src/__tests__/ReactWrongReturnPointer-test.js +++ b/packages/react-dom/src/__tests__/ReactWrongReturnPointer-test.js @@ -29,7 +29,7 @@ beforeEach(() => { Suspense = React.Suspense; if (gate(flags => flags.enableSuspenseList)) { - SuspenseList = React.SuspenseList; + SuspenseList = React.unstable_SuspenseList; } getCacheForType = React.unstable_getCacheForType; diff --git a/packages/react-is/src/__tests__/ReactIs-test.js b/packages/react-is/src/__tests__/ReactIs-test.js index a3738a4c83cca..5b63eebd529fd 100644 --- a/packages/react-is/src/__tests__/ReactIs-test.js +++ b/packages/react-is/src/__tests__/ReactIs-test.js @@ -23,7 +23,7 @@ describe('ReactIs', () => { ReactIs = require('react-is'); if (gate(flags => flags.enableSuspenseList)) { - SuspenseList = React.SuspenseList; + SuspenseList = React.unstable_SuspenseList; } }); diff --git a/packages/react-reconciler/src/__tests__/ReactContextPropagation-test.js b/packages/react-reconciler/src/__tests__/ReactContextPropagation-test.js index 4ddcffea42c2d..3247e8758e079 100644 --- a/packages/react-reconciler/src/__tests__/ReactContextPropagation-test.js +++ b/packages/react-reconciler/src/__tests__/ReactContextPropagation-test.js @@ -23,7 +23,7 @@ describe('ReactLazyContextPropagation', () => { useContext = React.useContext; Suspense = React.Suspense; if (gate(flags => flags.enableSuspenseList)) { - SuspenseList = React.SuspenseList; + SuspenseList = React.unstable_SuspenseList; } const InternalTestUtils = require('internal-test-utils'); diff --git a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js index 8e32084cf7c49..db67dde0d7e1b 100644 --- a/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js +++ b/packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js @@ -67,7 +67,7 @@ describe('ReactHooksWithNoopRenderer', () => { ContinuousEventPriority = require('react-reconciler/constants').ContinuousEventPriority; if (gate(flags => flags.enableSuspenseList)) { - SuspenseList = React.SuspenseList; + SuspenseList = React.unstable_SuspenseList; } const InternalTestUtils = require('internal-test-utils'); diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js index 42e758b4da8df..432546c683f5b 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js @@ -19,7 +19,7 @@ describe('ReactSuspenseList', () => { Profiler = React.Profiler; Suspense = React.Suspense; if (gate(flags => flags.enableSuspenseList)) { - SuspenseList = React.SuspenseList; + SuspenseList = React.unstable_SuspenseList; } const InternalTestUtils = require('internal-test-utils'); diff --git a/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js b/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js index 2a558ba93a523..6112cd2f4f3a5 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspenseyCommitPhase-test.js @@ -21,7 +21,7 @@ describe('ReactSuspenseyCommitPhase', () => { Scheduler = require('scheduler'); Suspense = React.Suspense; if (gate(flags => flags.enableSuspenseList)) { - SuspenseList = React.SuspenseList; + SuspenseList = React.unstable_SuspenseList; } Offscreen = React.unstable_Offscreen; useMemo = React.useMemo; diff --git a/packages/react/index.classic.fb.js b/packages/react/index.classic.fb.js index e5cbd5c95a24e..2d2c4ea8ff180 100644 --- a/packages/react/index.classic.fb.js +++ b/packages/react/index.classic.fb.js @@ -17,8 +17,6 @@ export { PureComponent, StrictMode, Suspense, - SuspenseList, - SuspenseList as unstable_SuspenseList, // TODO: Remove once call sights updated to SuspenseList cloneElement, createContext, createElement, @@ -38,6 +36,7 @@ export { unstable_LegacyHidden, unstable_Offscreen, unstable_Scope, + unstable_SuspenseList, unstable_getCacheSignal, unstable_getCacheForType, unstable_useCacheRefresh, diff --git a/packages/react/index.experimental.js b/packages/react/index.experimental.js index 1115946e61ca9..4bf5f67b74e8e 100644 --- a/packages/react/index.experimental.js +++ b/packages/react/index.experimental.js @@ -17,7 +17,6 @@ export { PureComponent, StrictMode, Suspense, - SuspenseList, cloneElement, createContext, createElement, @@ -36,6 +35,7 @@ export { unstable_Offscreen, unstable_getCacheSignal, unstable_getCacheForType, + unstable_SuspenseList, unstable_useCacheRefresh, unstable_useMemoCache, useId, diff --git a/packages/react/index.js b/packages/react/index.js index fd24be44fc13d..fd2c377668c21 100644 --- a/packages/react/index.js +++ b/packages/react/index.js @@ -40,7 +40,6 @@ export { PureComponent, StrictMode, Suspense, - SuspenseList, cloneElement, createContext, createElement, @@ -59,6 +58,7 @@ export { unstable_LegacyHidden, unstable_Offscreen, unstable_Scope, + unstable_SuspenseList, unstable_TracingMarker, unstable_getCacheSignal, unstable_getCacheForType, diff --git a/packages/react/index.modern.fb.js b/packages/react/index.modern.fb.js index 882240bb53cb2..2658db8acfc82 100644 --- a/packages/react/index.modern.fb.js +++ b/packages/react/index.modern.fb.js @@ -17,8 +17,6 @@ export { PureComponent, StrictMode, Suspense, - SuspenseList, - SuspenseList as unstable_SuspenseList, // TODO: Remove once call sights updated to SuspenseList cloneElement, createContext, createElement, @@ -36,6 +34,7 @@ export { unstable_LegacyHidden, unstable_Offscreen, unstable_Scope, + unstable_SuspenseList, unstable_getCacheSignal, unstable_getCacheForType, unstable_useCacheRefresh, diff --git a/packages/react/src/React.js b/packages/react/src/React.js index 579ef6279c3df..aff0401792f86 100644 --- a/packages/react/src/React.js +++ b/packages/react/src/React.js @@ -130,7 +130,7 @@ export { useTransition, startTransition, useDeferredValue, - REACT_SUSPENSE_LIST_TYPE as SuspenseList, + REACT_SUSPENSE_LIST_TYPE as unstable_SuspenseList, REACT_LEGACY_HIDDEN_TYPE as unstable_LegacyHidden, REACT_OFFSCREEN_TYPE as unstable_Offscreen, getCacheSignal as unstable_getCacheSignal, diff --git a/packages/react/src/ReactSharedSubset.experimental.js b/packages/react/src/ReactSharedSubset.experimental.js index 266fac65ea890..460c1fa19a6cf 100644 --- a/packages/react/src/ReactSharedSubset.experimental.js +++ b/packages/react/src/ReactSharedSubset.experimental.js @@ -17,7 +17,6 @@ export { Profiler, StrictMode, Suspense, - SuspenseList, cloneElement, createElement, createRef, @@ -30,6 +29,7 @@ export { cache, startTransition, unstable_DebugTracingMode, + unstable_SuspenseList, unstable_getCacheSignal, unstable_getCacheForType, useId,