Skip to content

Commit c4090d2

Browse files
author
Brian Vaughn
committed
Added SuspenseList to react-is experimental release
This commit also adds explicit index.stable and index.experimental forks to the react-is package so that we can avoid exporting references to SuspenseList in a stable release.
1 parent 4190a34 commit c4090d2

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
'use strict';
11+
12+
export {
13+
isValidElementType,
14+
typeOf,
15+
ContextConsumer,
16+
ContextProvider,
17+
Element,
18+
ForwardRef,
19+
Fragment,
20+
Lazy,
21+
Memo,
22+
Portal,
23+
Profiler,
24+
StrictMode,
25+
Suspense,
26+
SuspenseList,
27+
isAsyncMode,
28+
isConcurrentMode,
29+
isContextConsumer,
30+
isContextProvider,
31+
isElement,
32+
isForwardRef,
33+
isFragment,
34+
isLazy,
35+
isMemo,
36+
isPortal,
37+
isProfiler,
38+
isStrictMode,
39+
isSuspense,
40+
isSuspenseList,
41+
} from './src/ReactIs';

packages/react-is/index.stable.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
'use strict';
11+
12+
export {
13+
isValidElementType,
14+
typeOf,
15+
ContextConsumer,
16+
ContextProvider,
17+
Element,
18+
ForwardRef,
19+
Fragment,
20+
Lazy,
21+
Memo,
22+
Portal,
23+
Profiler,
24+
StrictMode,
25+
Suspense,
26+
isAsyncMode,
27+
isConcurrentMode,
28+
isContextConsumer,
29+
isContextProvider,
30+
isElement,
31+
isForwardRef,
32+
isFragment,
33+
isLazy,
34+
isMemo,
35+
isPortal,
36+
isProfiler,
37+
isStrictMode,
38+
isSuspense,
39+
} from './src/ReactIs';

packages/react-is/src/ReactIs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +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 SuspenseList = REACT_SUSPENSE_LIST_TYPE;
7576

7677
export {isValidElementType};
7778

@@ -142,3 +143,6 @@ export function isStrictMode(object: any) {
142143
export function isSuspense(object: any) {
143144
return typeOf(object) === REACT_SUSPENSE_TYPE;
144145
}
146+
export function isSuspenseList(object: any) {
147+
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
148+
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,18 @@ describe('ReactIs', () => {
186186
expect(ReactIs.isSuspense(<div />)).toBe(false);
187187
});
188188

189+
// @gate experimental
190+
it('should identify suspense list', () => {
191+
expect(ReactIs.isValidElementType(React.unstable_SuspenseList)).toBe(true);
192+
expect(ReactIs.typeOf(<React.unstable_SuspenseList />)).toBe(
193+
ReactIs.SuspenseList,
194+
);
195+
expect(ReactIs.isSuspenseList(<React.unstable_SuspenseList />)).toBe(true);
196+
expect(ReactIs.isSuspenseList({type: ReactIs.SuspenseList})).toBe(false);
197+
expect(ReactIs.isSuspenseList('React.SuspenseList')).toBe(false);
198+
expect(ReactIs.isSuspenseList(<div />)).toBe(false);
199+
});
200+
189201
it('should identify profile root', () => {
190202
expect(ReactIs.isValidElementType(React.Profiler)).toBe(true);
191203
expect(

0 commit comments

Comments
 (0)