File tree Expand file tree Collapse file tree 4 files changed +15
-5
lines changed Expand file tree Collapse file tree 4 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 1010'use strict' ;
1111
1212import {
13+ REACT_ASYNC_MODE_TYPE ,
1314 REACT_CONCURRENT_MODE_TYPE ,
1415 REACT_CONTEXT_TYPE ,
1516 REACT_ELEMENT_TYPE ,
@@ -32,6 +33,7 @@ export function typeOf(object: any) {
3233 const type = object . type ;
3334
3435 switch ( type ) {
36+ case REACT_ASYNC_MODE_TYPE :
3537 case REACT_CONCURRENT_MODE_TYPE :
3638 case REACT_FRAGMENT_TYPE :
3739 case REACT_PROFILER_TYPE :
@@ -57,8 +59,8 @@ export function typeOf(object: any) {
5759 return undefined ;
5860}
5961
60- // AsyncMode alias is deprecated along with isAsyncMode
61- export const AsyncMode = REACT_CONCURRENT_MODE_TYPE ;
62+ // AsyncMode is deprecated along with isAsyncMode
63+ export const AsyncMode = REACT_ASYNC_MODE_TYPE ;
6264export const ConcurrentMode = REACT_CONCURRENT_MODE_TYPE ;
6365export const ContextConsumer = REACT_CONTEXT_TYPE ;
6466export const ContextProvider = REACT_PROVIDER_TYPE ;
@@ -86,7 +88,7 @@ export function isAsyncMode(object: any) {
8688 ) ;
8789 }
8890 }
89- return isConcurrentMode ( object ) ;
91+ return isConcurrentMode ( object ) || typeOf ( object ) === REACT_ASYNC_MODE_TYPE ;
9092}
9193export function isConcurrentMode ( object : any ) {
9294 return typeOf ( object ) === REACT_CONCURRENT_MODE_TYPE ;
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ describe('ReactIs', () => {
6969 expect ( ReactIs . isValidElementType ( { type : 'div' , props : { } } ) ) . toEqual ( false ) ;
7070 } ) ;
7171
72- it ( 'should identify async mode' , ( ) => {
72+ it ( 'should identify concurrent mode' , ( ) => {
7373 expect ( ReactIs . typeOf ( < React . unstable_ConcurrentMode /> ) ) . toBe (
7474 ReactIs . ConcurrentMode ,
7575 ) ;
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ export const REACT_PROVIDER_TYPE = hasSymbol
3232export const REACT_CONTEXT_TYPE = hasSymbol
3333 ? Symbol . for ( 'react.context' )
3434 : 0xeace ;
35+ export const REACT_ASYNC_MODE_TYPE = hasSymbol
36+ ? Symbol . for ( 'react.async_mode' )
37+ : 0xeacf ;
3538export const REACT_CONCURRENT_MODE_TYPE = hasSymbol
3639 ? Symbol . for ( 'react.concurrent_mode' )
3740 : 0xeacf ;
Original file line number Diff line number Diff line change @@ -31,7 +31,12 @@ describe('ReactSymbols', () => {
3131 const originalSymbolFor = global . Symbol . for ;
3232 global . Symbol . for = null ;
3333 try {
34- expectToBeUnique ( Object . entries ( require ( 'shared/ReactSymbols' ) ) ) ;
34+ const entries = Object . entries ( require ( 'shared/ReactSymbols' ) ) . filter (
35+ // REACT_ASYNC_MODE_TYPE and REACT_CONCURRENT_MODE_TYPE have the same numeric value
36+ // for legacy backwards compatibility
37+ ( [ key ] ) => key !== 'REACT_ASYNC_MODE_TYPE' ,
38+ ) ;
39+ expectToBeUnique ( entries ) ;
3540 } finally {
3641 global . Symbol . for = originalSymbolFor ;
3742 }
You can’t perform that action at this time.
0 commit comments