GeezerVison is showing github.com — Add SuspenseList to react-is (#20874) · react/react@90bde65
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +41Lines changed: 41 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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 | + unstable_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 | + unstable_isSuspenseList, | | 41 | +} from './src/ReactIs'; |
Collapse file Copy file name to clipboard +39Lines changed: 39 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 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'; |
Collapse file Copy file name to clipboardExpand all lines: packages/react-is/src/ReactIs.js +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -72,6 +72,7 @@ export const Portal = REACT_PORTAL_TYPE; | 72 | 72 | export const Profiler = REACT_PROFILER_TYPE; | 73 | 73 | export const StrictMode = REACT_STRICT_MODE_TYPE; | 74 | 74 | export const Suspense = REACT_SUSPENSE_TYPE; | | 75 | +export const unstable_SuspenseList = REACT_SUSPENSE_LIST_TYPE; | 75 | 76 |
| 76 | 77 | export {isValidElementType}; | 77 | 78 |
| @@ -142,3 +143,6 @@ export function isStrictMode(object: any) { | 142 | 143 | export function isSuspense(object: any) { | 143 | 144 | return typeOf(object) === REACT_SUSPENSE_TYPE; | 144 | 145 | } | | 146 | +export function unstable_isSuspenseList(object: any) { | | 147 | + return typeOf(object) === REACT_SUSPENSE_LIST_TYPE; | | 148 | +} |
Collapse file Copy file name to clipboardExpand all lines: packages/react-is/src/__tests__/ReactIs-test.js +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -186,6 +186,24 @@ describe('ReactIs', () => { | 186 | 186 | expect(ReactIs.isSuspense(<div />)).toBe(false); | 187 | 187 | }); | 188 | 188 |
| | 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.unstable_SuspenseList, | | 194 | + ); | | 195 | + expect( | | 196 | + ReactIs.unstable_isSuspenseList(<React.unstable_SuspenseList />), | | 197 | + ).toBe(true); | | 198 | + expect( | | 199 | + ReactIs.unstable_isSuspenseList({type: ReactIs.unstable_SuspenseList}), | | 200 | + ).toBe(false); | | 201 | + expect(ReactIs.unstable_isSuspenseList('React.unstable_SuspenseList')).toBe( | | 202 | + false, | | 203 | + ); | | 204 | + expect(ReactIs.unstable_isSuspenseList(<div />)).toBe(false); | | 205 | + }); | | 206 | + | 189 | 207 | it('should identify profile root', () => { | 190 | 208 | expect(ReactIs.isValidElementType(React.Profiler)).toBe(true); | 191 | 209 | expect( | |
|