Skip to content

Commit 8a0e2ab

Browse files
author
Brian Vaughn
committed
Promote concurrent mode APIs from experimental to stable
1 parent ea9b1ad commit 8a0e2ab

26 files changed

+50
-118
lines changed

packages/react-devtools-scheduling-profiler/src/hooks.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
* @flow
88
*/
99

10-
import {
11-
unstable_createMutableSource as createMutableSource,
12-
unstable_useMutableSource as useMutableSource,
13-
useLayoutEffect,
14-
} from 'react';
10+
import {createMutableSource, useMutableSource, useLayoutEffect} from 'react';
1511

1612
import {
1713
updateDisplayDensity,

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import * as React from 'react';
1111
import {
1212
createContext,
13-
unstable_startTransition as startTransition,
13+
startTransition,
1414
unstable_useCacheRefresh as useCacheRefresh,
1515
useCallback,
1616
useContext,

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementErrorsAndWarningsTree.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as React from 'react';
1111
import {
1212
useContext,
1313
unstable_useCacheRefresh as useCacheRefresh,
14-
unstable_useTransition as useTransition,
14+
useTransition,
1515
} from 'react';
1616
import Button from '../Button';
1717
import ButtonIcon from '../ButtonIcon';

packages/react-devtools-shared/src/devtools/views/Components/KeyValue.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
*/
99

1010
import * as React from 'react';
11-
import {
12-
unstable_useTransition as useTransition,
13-
useContext,
14-
useRef,
15-
useState,
16-
} from 'react';
11+
import {useTransition, useContext, useRef, useState} from 'react';
1712
import EditableName from './EditableName';
1813
import EditableValue from './EditableValue';
1914
import NewArrayValue from './NewArrayValue';

packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
useMemo,
3535
useReducer,
3636
useRef,
37-
unstable_startTransition as startTransition,
37+
startTransition,
3838
} from 'react';
3939
import {createRegExp} from '../utils';
4040
import {BridgeContext, StoreContext} from '../context';

packages/react-devtools-shared/src/devtools/views/ErrorBoundary/cache.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import type {Wakeable} from 'shared/ReactTypes';
1111
import type {GitHubIssue} from './githubAPI';
1212

13-
import {unstable_getCacheForType} from 'react';
13+
import {unstable_getCacheForType as getCacheForType} from 'react';
1414
import {searchGitHubIssues} from './githubAPI';
1515

1616
const API_TIMEOUT = 3000;
@@ -55,7 +55,7 @@ function createMap(): GitHubIssueMap {
5555
}
5656

5757
function getRecordMap(): Map<string, Record<GitHubIssue>> {
58-
return unstable_getCacheForType(createMap);
58+
return getCacheForType(createMap);
5959
}
6060

6161
export function findGitHubIssue(errorMessage: string): GitHubIssue | null {

packages/react-devtools-shared/src/inspectedElementCache.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
*/
99

1010
import {
11-
unstable_getCacheForType,
12-
unstable_startTransition as startTransition,
11+
unstable_getCacheForType as getCacheForType,
12+
startTransition,
1313
} from 'react';
1414
import Store from './devtools/store';
1515
import {inspectElement as inspectElementMutableSource} from './inspectedElementMutableSource';
@@ -60,7 +60,7 @@ function createMap(): InspectedElementMap {
6060
}
6161

6262
function getRecordMap(): WeakMap<Element, Record<InspectedElementFrontend>> {
63-
return unstable_getCacheForType(createMap);
63+
return getCacheForType(createMap);
6464
}
6565

6666
function createCacheSeed(

packages/react-devtools-shell/src/app/SuspenseTree/index.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
*/
99

1010
import * as React from 'react';
11-
import {
12-
Fragment,
13-
Suspense,
14-
unstable_SuspenseList as SuspenseList,
15-
useState,
16-
} from 'react';
11+
import {Fragment, Suspense, SuspenseList, useState} from 'react';
1712

1813
function SuspenseTree() {
1914
return (

packages/react-dom/index.classic.fb.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ export {
2222
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
2323
createPortal,
2424
createRoot,
25-
createRoot as unstable_createRoot,
25+
createRoot as unstable_createRoot, // TODO Remove once callsites use createRoot
2626
findDOMNode,
2727
flushSync,
2828
hydrate,
2929
render,
3030
unmountComponentAtNode,
3131
unstable_batchedUpdates,
3232
unstable_createEventHandle,
33-
unstable_createPortal, // Temporary alias
3433
unstable_flushControlled,
3534
unstable_isNewReconciler,
3635
unstable_renderSubtreeIntoContainer,

packages/react-dom/index.experimental.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
export {
1111
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
1212
createPortal,
13-
createRoot as unstable_createRoot,
13+
createRoot,
1414
findDOMNode,
1515
flushSync,
1616
hydrate,
1717
render,
1818
unmountComponentAtNode,
1919
unstable_batchedUpdates,
20-
unstable_createPortal, // Temporary alias
2120
unstable_flushControlled,
2221
unstable_renderSubtreeIntoContainer,
2322
unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.

packages/react-dom/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export {
2121
unmountComponentAtNode,
2222
unstable_batchedUpdates,
2323
unstable_createEventHandle,
24-
unstable_createPortal, // Temporary alias
2524
unstable_flushControlled,
2625
unstable_isNewReconciler,
2726
unstable_renderSubtreeIntoContainer,

packages/react-dom/index.modern.fb.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export {
1111
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
1212
createPortal,
1313
createRoot,
14-
createRoot as unstable_createRoot,
14+
createRoot as unstable_createRoot, // TODO Remove once callsites use createRoot
1515
flushSync,
1616
unstable_batchedUpdates,
1717
unstable_createEventHandle,

packages/react-dom/index.stable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
export {
1111
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
1212
createPortal,
13+
createRoot,
1314
findDOMNode,
1415
flushSync,
1516
hydrate,
1617
render,
1718
unmountComponentAtNode,
1819
unstable_batchedUpdates,
19-
unstable_createPortal, // Temporary alias
2020
unstable_renderSubtreeIntoContainer,
2121
version,
2222
} from './src/client/ReactDOM';

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

-28
Original file line numberDiff line numberDiff line change
@@ -246,34 +246,6 @@ describe('ReactDOMFiber', () => {
246246
expect(container.innerHTML).toBe('');
247247
});
248248

249-
// TODO: remove in React 18
250-
if (!__EXPERIMENTAL__) {
251-
it('should support unstable_createPortal alias', () => {
252-
const portalContainer = document.createElement('div');
253-
254-
expect(() =>
255-
ReactDOM.render(
256-
<div>
257-
{ReactDOM.unstable_createPortal(<div>portal</div>, portalContainer)}
258-
</div>,
259-
container,
260-
),
261-
).toWarnDev(
262-
'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
263-
'and will be removed in React 18+. Update your code to use ' +
264-
'ReactDOM.createPortal() instead. It has the exact same API, ' +
265-
'but without the "unstable_" prefix.',
266-
{withoutStack: true},
267-
);
268-
expect(portalContainer.innerHTML).toBe('<div>portal</div>');
269-
expect(container.innerHTML).toBe('<div></div>');
270-
271-
ReactDOM.unmountComponentAtNode(container);
272-
expect(portalContainer.innerHTML).toBe('');
273-
expect(container.innerHTML).toBe('');
274-
});
275-
}
276-
277249
it('should render many portals', () => {
278250
const portalContainer1 = document.createElement('div');
279251
const portalContainer2 = document.createElement('div');

packages/react-dom/src/client/ReactDOM.js

-24
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority);
7878
setGetCurrentUpdatePriority(getCurrentUpdatePriority);
7979
setAttemptHydrationAtPriority(runWithPriority);
8080

81-
let didWarnAboutUnstableCreatePortal = false;
8281
let didWarnAboutUnstableRenderSubtreeIntoContainer = false;
8382

8483
if (__DEV__) {
@@ -155,25 +154,6 @@ function renderSubtreeIntoContainer(
155154
);
156155
}
157156

158-
function unstable_createPortal(
159-
children: ReactNodeList,
160-
container: Container,
161-
key: ?string = null,
162-
) {
163-
if (__DEV__) {
164-
if (!didWarnAboutUnstableCreatePortal) {
165-
didWarnAboutUnstableCreatePortal = true;
166-
console.warn(
167-
'The ReactDOM.unstable_createPortal() alias has been deprecated, ' +
168-
'and will be removed in React 18+. Update your code to use ' +
169-
'ReactDOM.createPortal() instead. It has the exact same API, ' +
170-
'but without the "unstable_" prefix.',
171-
);
172-
}
173-
}
174-
return createPortal(children, container, key);
175-
}
176-
177157
const Internals = {
178158
// Keep in sync with ReactTestUtils.js, and ReactTestUtilsAct.js.
179159
// This is an array for better minification.
@@ -206,10 +186,6 @@ export {
206186
scheduleHydration as unstable_scheduleHydration,
207187
// Disabled behind disableUnstableRenderSubtreeIntoContainer
208188
renderSubtreeIntoContainer as unstable_renderSubtreeIntoContainer,
209-
// Disabled behind disableUnstableCreatePortal
210-
// Temporary alias since we already shipped React 16 RC with it.
211-
// TODO: remove in React 18.
212-
unstable_createPortal,
213189
// enableCreateEventHandleAPI
214190
createEventHandle as unstable_createEventHandle,
215191
// TODO: Remove this once callers migrate to alternatives.

packages/react-is/index.experimental.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export {
2323
Profiler,
2424
StrictMode,
2525
Suspense,
26-
unstable_SuspenseList,
26+
SuspenseList,
2727
isAsyncMode,
2828
isConcurrentMode,
2929
isContextConsumer,
@@ -37,5 +37,5 @@ export {
3737
isProfiler,
3838
isStrictMode,
3939
isSuspense,
40-
unstable_isSuspenseList,
40+
isSuspenseList,
4141
} from './src/ReactIs';

packages/react-is/index.stable.js

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export {
2323
Profiler,
2424
StrictMode,
2525
Suspense,
26+
SuspenseList,
2627
isAsyncMode,
2728
isConcurrentMode,
2829
isContextConsumer,
@@ -36,4 +37,5 @@ export {
3637
isProfiler,
3738
isStrictMode,
3839
isSuspense,
40+
isSuspenseList,
3941
} from './src/ReactIs';

packages/react-is/src/ReactIs.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const Portal = REACT_PORTAL_TYPE;
7272
export const Profiler = REACT_PROFILER_TYPE;
7373
export const StrictMode = REACT_STRICT_MODE_TYPE;
7474
export const Suspense = REACT_SUSPENSE_TYPE;
75-
export const unstable_SuspenseList = REACT_SUSPENSE_LIST_TYPE;
75+
export const SuspenseList = REACT_SUSPENSE_LIST_TYPE;
7676

7777
export {isValidElementType};
7878

@@ -143,6 +143,6 @@ export function isStrictMode(object: any) {
143143
export function isSuspense(object: any) {
144144
return typeOf(object) === REACT_SUSPENSE_TYPE;
145145
}
146-
export function unstable_isSuspenseList(object: any) {
146+
export function isSuspenseList(object: any) {
147147
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
148148
}

packages/react-is/src/__tests__/ReactIs-test.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,21 @@ describe('ReactIs', () => {
186186
expect(ReactIs.isSuspense(<div />)).toBe(false);
187187
});
188188

189-
// @gate experimental
190189
it('should identify suspense list', () => {
191-
expect(ReactIs.isValidElementType(React.unstable_SuspenseList)).toBe(true);
192-
expect(ReactIs.typeOf(<React.unstable_SuspenseList />)).toBe(
193-
ReactIs.unstable_SuspenseList,
190+
expect(ReactIs.isValidElementType(React.SuspenseList)).toBe(true);
191+
expect(ReactIs.typeOf(<React.SuspenseList />)).toBe(
192+
ReactIs.SuspenseList,
194193
);
195194
expect(
196-
ReactIs.unstable_isSuspenseList(<React.unstable_SuspenseList />),
195+
ReactIs.isSuspenseList(<React.SuspenseList />),
197196
).toBe(true);
198197
expect(
199-
ReactIs.unstable_isSuspenseList({type: ReactIs.unstable_SuspenseList}),
198+
ReactIs.isSuspenseList({type: ReactIs.SuspenseList}),
200199
).toBe(false);
201-
expect(ReactIs.unstable_isSuspenseList('React.unstable_SuspenseList')).toBe(
200+
expect(ReactIs.isSuspenseList('React.SuspenseList')).toBe(
202201
false,
203202
);
204-
expect(ReactIs.unstable_isSuspenseList(<div />)).toBe(false);
203+
expect(ReactIs.isSuspenseList(<div />)).toBe(false);
205204
});
206205

207206
it('should identify profile root', () => {

packages/react/index.classic.fb.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export {
1717
StrictMode,
1818
Suspense,
1919
SuspenseList,
20-
SuspenseList as unstable_SuspenseList,
20+
SuspenseList as unstable_SuspenseList, // TODO: Remove once call sights updated to SuspenseList
2121
cloneElement,
2222
createContext,
2323
createElement,
@@ -30,7 +30,7 @@ export {
3030
lazy,
3131
memo,
3232
startTransition,
33-
startTransition as unstable_startTransition,
33+
startTransition as unstable_startTransition, // TODO: Remove once call sights updated to startTransition
3434
unstable_Cache,
3535
unstable_DebugTracingMode,
3636
unstable_LegacyHidden,
@@ -42,7 +42,7 @@ export {
4242
useContext,
4343
useDebugValue,
4444
useDeferredValue,
45-
useDeferredValue as unstable_useDeferredValue,
45+
useDeferredValue as unstable_useDeferredValue, // TODO: Remove once call sights updated to useDeferredValue
4646
useEffect,
4747
useImperativeHandle,
4848
useLayoutEffect,
@@ -53,7 +53,7 @@ export {
5353
useRef,
5454
useState,
5555
useTransition,
56-
useTransition as unstable_useTransition,
56+
useTransition as unstable_useTransition, // TODO: Remove once call sights updated to useTransition
5757
version,
5858
} from './src/React';
5959
export {jsx, jsxs, jsxDEV} from './src/jsx/ReactJSX';

packages/react/index.experimental.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export {
1616
PureComponent,
1717
StrictMode,
1818
Suspense,
19-
SuspenseList as unstable_SuspenseList,
19+
SuspenseList,
2020
cloneElement,
2121
createContext,
2222
createElement,
@@ -27,7 +27,7 @@ export {
2727
isValidElement,
2828
lazy,
2929
memo,
30-
startTransition as unstable_startTransition,
30+
startTransition,
3131
unstable_Cache,
3232
unstable_DebugTracingMode,
3333
unstable_LegacyHidden,
@@ -37,7 +37,6 @@ export {
3737
useCallback,
3838
useContext,
3939
useDebugValue,
40-
useDeferredValue as unstable_useDeferredValue,
4140
useEffect,
4241
useImperativeHandle,
4342
useLayoutEffect,
@@ -46,6 +45,6 @@ export {
4645
useReducer,
4746
useRef,
4847
useState,
49-
useTransition as unstable_useTransition,
48+
useTransition,
5049
version,
5150
} from './src/React';

0 commit comments

Comments
 (0)