@@ -18,12 +18,14 @@ import {
18
18
REACT_MEMO_TYPE ,
19
19
REACT_PORTAL_TYPE ,
20
20
REACT_PROFILER_TYPE ,
21
+ REACT_PROVIDER_TYPE ,
21
22
REACT_CONSUMER_TYPE ,
22
23
REACT_STRICT_MODE_TYPE ,
23
24
REACT_SUSPENSE_TYPE ,
24
25
REACT_SUSPENSE_LIST_TYPE ,
25
26
} from 'shared/ReactSymbols' ;
26
27
import isValidElementType from 'shared/isValidElementType' ;
28
+ import { enableRenderableContext } from 'shared/ReactFeatureFlags' ;
27
29
28
30
export function typeOf ( object : any ) : mixed {
29
31
if ( typeof object === 'object' && object !== null ) {
@@ -47,8 +49,17 @@ export function typeOf(object: any): mixed {
47
49
case REACT_FORWARD_REF_TYPE :
48
50
case REACT_LAZY_TYPE :
49
51
case REACT_MEMO_TYPE :
50
- case REACT_CONSUMER_TYPE :
51
52
return $$typeofType ;
53
+ case REACT_CONSUMER_TYPE :
54
+ if ( enableRenderableContext ) {
55
+ return $$typeofType ;
56
+ }
57
+ // Fall through
58
+ case REACT_PROVIDER_TYPE :
59
+ if ( ! enableRenderableContext ) {
60
+ return $$typeofType ;
61
+ }
62
+ // Fall through
52
63
default :
53
64
return $$typeof ;
54
65
}
@@ -61,8 +72,12 @@ export function typeOf(object: any): mixed {
61
72
return undefined ;
62
73
}
63
74
64
- export const ContextConsumer = REACT_CONSUMER_TYPE ;
65
- export const ContextProvider = REACT_CONTEXT_TYPE ;
75
+ export const ContextConsumer : symbol = enableRenderableContext
76
+ ? REACT_CONSUMER_TYPE
77
+ : REACT_CONTEXT_TYPE ;
78
+ export const ContextProvider : symbol = enableRenderableContext
79
+ ? REACT_CONTEXT_TYPE
80
+ : REACT_PROVIDER_TYPE ;
66
81
export const Element = REACT_ELEMENT_TYPE ;
67
82
export const ForwardRef = REACT_FORWARD_REF_TYPE ;
68
83
export const Fragment = REACT_FRAGMENT_TYPE ;
@@ -77,10 +92,18 @@ export const SuspenseList = REACT_SUSPENSE_LIST_TYPE;
77
92
export { isValidElementType } ;
78
93
79
94
export function isContextConsumer ( object : any ) : boolean {
80
- return typeOf ( object ) === REACT_CONSUMER_TYPE ;
95
+ if ( enableRenderableContext ) {
96
+ return typeOf ( object ) === REACT_CONSUMER_TYPE ;
97
+ } else {
98
+ return typeOf ( object ) === REACT_CONTEXT_TYPE ;
99
+ }
81
100
}
82
101
export function isContextProvider ( object : any ) : boolean {
83
- return typeOf ( object ) === REACT_CONTEXT_TYPE ;
102
+ if ( enableRenderableContext ) {
103
+ return typeOf ( object ) === REACT_CONTEXT_TYPE ;
104
+ } else {
105
+ return typeOf ( object ) === REACT_PROVIDER_TYPE ;
106
+ }
84
107
}
85
108
export function isElement ( object : any ) : boolean {
86
109
return (
0 commit comments