Skip to content

Commit d75c69e

Browse files
authored
Remove unstable_ prefix from Suspense (#13922)
We are using it with lazy and the combination Suspense + lazy seems pretty stable. maxDuration is not but that's only enabled when you're in ConcurrentMode which is still unstable.
1 parent c8ef2fe commit d75c69e

16 files changed

+42
-45
lines changed

fixtures/dom/src/components/fixtures/suspense/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import TestCase from '../../TestCase';
55
const React = window.React;
66
const ReactDOM = window.ReactDOM;
77

8-
const Suspense = React.unstable_Suspense;
8+
const Suspense = React.Suspense;
99

1010
let cache = new Set();
1111

fixtures/unstable-async/suspense/src/components/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {lazy, unstable_Suspense as Suspense, PureComponent} from 'react';
1+
import React, {lazy, Suspense, PureComponent} from 'react';
22
import {unstable_scheduleCallback} from 'scheduler';
33
import {
44
unstable_trace as trace,

fixtures/unstable-async/suspense/src/components/UserPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {unstable_Suspense as Suspense} from 'react';
1+
import React, {Suspense} from 'react';
22
import {createResource} from 'react-cache';
33
import Spinner from './Spinner';
44
import {cache} from '../cache';

packages/react-dom/src/__tests__/ReactDOMServerSuspense-test.internal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ describe('ReactDOMServerSuspense', () => {
4848
throw new Promise(() => {});
4949
};
5050
const e = await serverRender(
51-
<React.unstable_Suspense fallback={<div />}>
51+
<React.Suspense fallback={<div />}>
5252
<Suspended />
53-
</React.unstable_Suspense>,
53+
</React.Suspense>,
5454
);
5555

5656
expect(e.tagName).toBe('DIV');

packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.internal.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ describe('ReactDOMSuspensePlaceholder', () => {
2323
beforeEach(() => {
2424
jest.resetModules();
2525
ReactFeatureFlags = require('shared/ReactFeatureFlags');
26-
ReactFeatureFlags.enableSuspense = true;
2726
React = require('react');
2827
ReactDOM = require('react-dom');
2928
ReactCache = require('react-cache');
30-
Suspense = React.unstable_Suspense;
29+
Suspense = React.Suspense;
3130
container = document.createElement('div');
3231

3332
function invalidateCache() {

packages/react-dom/src/__tests__/ReactServerRendering-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ describe('ReactDOMServer', () => {
610610

611611
it('throws for unsupported types on the server', () => {
612612
expect(() => {
613-
ReactDOMServer.renderToString(<React.unstable_Suspense />);
613+
ReactDOMServer.renderToString(<React.Suspense />);
614614
}).toThrow('ReactDOMServer does not yet support Suspense.');
615615

616616
async function fakeImport(result) {

packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,9 @@ describe('ReactDOMServerHydration', () => {
470470
<div>
471471
Hello{' '}
472472
{this.state.isClient && (
473-
<React.unstable_Suspense fallback="loading">
473+
<React.Suspense fallback="loading">
474474
<Lazy />
475-
</React.unstable_Suspense>
475+
</React.Suspense>
476476
)}
477477
</div>
478478
);

packages/react-reconciler/src/__tests__/ReactIncrementalPerf-test.internal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,9 @@ describe('ReactDebugFiberPerf', () => {
587587

588588
ReactNoop.render(
589589
<Parent>
590-
<React.unstable_Suspense fallback={<Spinner />}>
590+
<React.Suspense fallback={<Spinner />}>
591591
<LazyFoo />
592-
</React.unstable_Suspense>
592+
</React.Suspense>
593593
</Parent>,
594594
);
595595
ReactNoop.flush();
@@ -605,9 +605,9 @@ describe('ReactDebugFiberPerf', () => {
605605

606606
ReactNoop.render(
607607
<Parent>
608-
<React.unstable_Suspense>
608+
<React.Suspense>
609609
<LazyFoo />
610-
</React.unstable_Suspense>
610+
</React.Suspense>
611611
</Parent>,
612612
);
613613
ReactNoop.flush();

packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('ReactLazy', () => {
1111
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
1212
ReactFeatureFlags.replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
1313
React = require('react');
14-
Suspense = React.unstable_Suspense;
14+
Suspense = React.Suspense;
1515
lazy = React.lazy;
1616
ReactTestRenderer = require('react-test-renderer');
1717
});

packages/react-reconciler/src/__tests__/ReactMemo-test.internal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('memo', () => {
5656
function sharedTests(label, memo) {
5757
describe(`${label}`, () => {
5858
it('bails out on props equality', async () => {
59-
const {unstable_Suspense: Suspense} = React;
59+
const {Suspense} = React;
6060

6161
function Counter({count}) {
6262
return <Text text={count} />;
@@ -93,7 +93,7 @@ describe('memo', () => {
9393
});
9494

9595
it("does not bail out if there's a context change", async () => {
96-
const {unstable_Suspense: Suspense} = React;
96+
const {Suspense} = React;
9797

9898
const CountContext = React.createContext(0);
9999

@@ -142,7 +142,7 @@ describe('memo', () => {
142142
});
143143

144144
it('accepts custom comparison function', async () => {
145-
const {unstable_Suspense: Suspense} = React;
145+
const {Suspense} = React;
146146

147147
function Counter({count}) {
148148
return <Text text={count} />;
@@ -184,7 +184,7 @@ describe('memo', () => {
184184
});
185185

186186
it('supports non-pure class components', async () => {
187-
const {unstable_Suspense: Suspense} = React;
187+
const {Suspense} = React;
188188

189189
class CounterInner extends React.Component {
190190
static defaultProps = {suffix: '!'};

packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('ReactSuspense', () => {
2323
// JestReact = require('jest-react');
2424
ReactCache = require('react-cache');
2525

26-
Suspense = React.unstable_Suspense;
26+
Suspense = React.Suspense;
2727

2828
function invalidateCache() {
2929
cache = ReactCache.createCache(invalidateCache);

packages/react-reconciler/src/__tests__/ReactSuspensePlaceholder-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function runPlaceholderTests(suiteLabel, loadReactNoop) {
3737
// JestReact = require('jest-react');
3838
ReactCache = require('react-cache');
3939

40-
Suspense = React.unstable_Suspense;
40+
Suspense = React.Suspense;
4141

4242
function invalidateCache() {
4343
cache = ReactCache.createCache(invalidateCache);

packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
2424
Fragment = React.Fragment;
2525
ReactNoop = require('react-noop-renderer');
2626
ReactCache = require('react-cache');
27-
Suspense = React.unstable_Suspense;
27+
Suspense = React.Suspense;
2828
StrictMode = React.StrictMode;
2929
ConcurrentMode = React.unstable_ConcurrentMode;
3030

packages/react/src/React.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const React = {
5555
Fragment: REACT_FRAGMENT_TYPE,
5656
StrictMode: REACT_STRICT_MODE_TYPE,
5757
unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
58-
unstable_Suspense: REACT_SUSPENSE_TYPE,
58+
Suspense: REACT_SUSPENSE_TYPE,
5959
unstable_Profiler: REACT_PROFILER_TYPE,
6060

6161
createElement: __DEV__ ? createElementWithValidation : createElement,

packages/react/src/__tests__/ReactProfiler-test.internal.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,9 +2228,9 @@ describe('Profiler', () => {
22282228
SchedulerTracing.unstable_trace(interaction.name, mockNow(), () => {
22292229
ReactNoop.render(
22302230
<React.unstable_Profiler id="test-profiler" onRender={onRender}>
2231-
<React.unstable_Suspense fallback={<Text text="Loading..." />}>
2231+
<React.Suspense fallback={<Text text="Loading..." />}>
22322232
<AsyncText text="Async" ms={20000} />
2233-
</React.unstable_Suspense>
2233+
</React.Suspense>
22342234
<Text text="Sync" />
22352235
<Monkey ref={monkey} />
22362236
</React.unstable_Profiler>,
@@ -2316,11 +2316,11 @@ describe('Profiler', () => {
23162316
() => {
23172317
ReactTestRenderer.create(
23182318
<React.unstable_Profiler id="app" onRender={onRender}>
2319-
<React.unstable_Suspense
2319+
<React.Suspense
23202320
maxDuration={1000}
23212321
fallback={<Text text="loading" />}>
23222322
<AsyncText text="loaded" ms={2000} />
2323-
</React.unstable_Suspense>
2323+
</React.Suspense>
23242324
</React.unstable_Profiler>,
23252325
);
23262326
},
@@ -2370,11 +2370,11 @@ describe('Profiler', () => {
23702370
() => {
23712371
ReactTestRenderer.create(
23722372
<React.unstable_Profiler id="app" onRender={onRender}>
2373-
<React.unstable_Suspense
2373+
<React.Suspense
23742374
maxDuration={1000}
23752375
fallback={<Text text="loading" />}>
23762376
<AsyncComponentWithCascadingWork text="loaded" ms={2000} />
2377-
</React.unstable_Suspense>
2377+
</React.Suspense>
23782378
</React.unstable_Profiler>,
23792379
);
23802380
},
@@ -2410,11 +2410,11 @@ describe('Profiler', () => {
24102410
() => {
24112411
renderer = ReactTestRenderer.create(
24122412
<React.unstable_Profiler id="app" onRender={onRender}>
2413-
<React.unstable_Suspense
2413+
<React.Suspense
24142414
maxDuration={1000}
24152415
fallback={<Text text="loading" />}>
24162416
<AsyncText text="loaded" ms={2000} />
2417-
</React.unstable_Suspense>
2417+
</React.Suspense>
24182418
</React.unstable_Profiler>,
24192419
{
24202420
unstable_isConcurrent: true,
@@ -2458,11 +2458,11 @@ describe('Profiler', () => {
24582458
() => {
24592459
renderer = ReactTestRenderer.create(
24602460
<React.unstable_Profiler id="app" onRender={onRender}>
2461-
<React.unstable_Suspense
2461+
<React.Suspense
24622462
maxDuration={2000}
24632463
fallback={<Text text="loading" />}>
24642464
<AsyncText text="loaded" ms={1000} />
2465-
</React.unstable_Suspense>
2465+
</React.Suspense>
24662466
</React.unstable_Profiler>,
24672467
{unstable_isConcurrent: true},
24682468
);
@@ -2497,11 +2497,11 @@ describe('Profiler', () => {
24972497
() => {
24982498
renderer = ReactTestRenderer.create(
24992499
<React.unstable_Profiler id="app" onRender={onRender}>
2500-
<React.unstable_Suspense
2500+
<React.Suspense
25012501
maxDuration={2000}
25022502
fallback={<Text text="loading" />}>
25032503
<AsyncText text="loaded" ms={1000} />
2504-
</React.unstable_Suspense>
2504+
</React.Suspense>
25052505
<Text text="initial" />
25062506
</React.unstable_Profiler>,
25072507
);
@@ -2531,11 +2531,11 @@ describe('Profiler', () => {
25312531
() => {
25322532
renderer.update(
25332533
<React.unstable_Profiler id="app" onRender={onRender}>
2534-
<React.unstable_Suspense
2534+
<React.Suspense
25352535
maxDuration={2000}
25362536
fallback={<Text text="loading" />}>
25372537
<AsyncText text="loaded" ms={1000} />
2538-
</React.unstable_Suspense>
2538+
</React.Suspense>
25392539
<Text text="updated" />
25402540
</React.unstable_Profiler>,
25412541
);
@@ -2593,11 +2593,11 @@ describe('Profiler', () => {
25932593
() => {
25942594
renderer = ReactTestRenderer.create(
25952595
<React.unstable_Profiler id="app" onRender={onRender}>
2596-
<React.unstable_Suspense
2596+
<React.Suspense
25972597
maxDuration={2000}
25982598
fallback={<Text text="loading" />}>
25992599
<AsyncText text="loaded" ms={1000} />
2600-
</React.unstable_Suspense>
2600+
</React.Suspense>
26012601
<Text text="initial" />
26022602
</React.unstable_Profiler>,
26032603
{unstable_isConcurrent: true},
@@ -2631,11 +2631,11 @@ describe('Profiler', () => {
26312631
() => {
26322632
renderer.update(
26332633
<React.unstable_Profiler id="app" onRender={onRender}>
2634-
<React.unstable_Suspense
2634+
<React.Suspense
26352635
maxDuration={2000}
26362636
fallback={<Text text="loading" />}>
26372637
<AsyncText text="loaded" ms={1000} />
2638-
</React.unstable_Suspense>
2638+
</React.Suspense>
26392639
<Text text="updated" />
26402640
</React.unstable_Profiler>,
26412641
);

packages/react/src/__tests__/ReactProfilerDOM-test.internal.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,9 @@ describe('ProfilerDOM', () => {
119119
const root = ReactDOM.unstable_createRoot(element);
120120
batch = root.createBatch();
121121
batch.render(
122-
<React.unstable_Suspense
123-
maxDuration={100}
124-
fallback={<Text text="Loading..." />}>
122+
<React.Suspense maxDuration={100} fallback={<Text text="Loading..." />}>
125123
<AsyncText text="Text" ms={200} />
126-
</React.unstable_Suspense>,
124+
</React.Suspense>,
127125
);
128126
batch.then(
129127
SchedulerTracing.unstable_wrap(() => {

0 commit comments

Comments
 (0)