@@ -18,12 +18,14 @@ import {
1818 REACT_MEMO_TYPE ,
1919 REACT_PORTAL_TYPE ,
2020 REACT_PROFILER_TYPE ,
21+ REACT_PROVIDER_TYPE ,
2122 REACT_CONSUMER_TYPE ,
2223 REACT_STRICT_MODE_TYPE ,
2324 REACT_SUSPENSE_TYPE ,
2425 REACT_SUSPENSE_LIST_TYPE ,
2526} from 'shared/ReactSymbols' ;
2627import isValidElementType from 'shared/isValidElementType' ;
28+ import { enableRenderableContext } from 'shared/ReactFeatureFlags' ;
2729
2830export function typeOf ( object : any ) : mixed {
2931 if ( typeof object === 'object' && object !== null ) {
@@ -47,8 +49,19 @@ export function typeOf(object: any): mixed {
4749 case REACT_FORWARD_REF_TYPE :
4850 case REACT_LAZY_TYPE :
4951 case REACT_MEMO_TYPE :
50- case REACT_CONSUMER_TYPE :
5152 return $$typeofType ;
53+ case REACT_CONSUMER_TYPE :
54+ if ( enableRenderableContext ) {
55+ return $$typeofType ;
56+ } else {
57+ // Fallthrough to default
58+ }
59+ case REACT_PROVIDER_TYPE :
60+ if ( enableRenderableContext ) {
61+ // Fallthrough to default
62+ } else {
63+ return $$typeofType ;
64+ }
5265 default :
5366 return $$typeof ;
5467 }
@@ -61,8 +74,12 @@ export function typeOf(object: any): mixed {
6174 return undefined ;
6275}
6376
64- export const ContextConsumer = REACT_CONSUMER_TYPE ;
65- export const ContextProvider = REACT_CONTEXT_TYPE ;
77+ export const ContextConsumer : symbol = enableRenderableContext
78+ ? REACT_CONSUMER_TYPE
79+ : REACT_CONTEXT_TYPE ;
80+ export const ContextProvider : symbol = enableRenderableContext
81+ ? REACT_CONTEXT_TYPE
82+ : REACT_PROVIDER_TYPE ;
6683export const Element = REACT_ELEMENT_TYPE ;
6784export const ForwardRef = REACT_FORWARD_REF_TYPE ;
6885export const Fragment = REACT_FRAGMENT_TYPE ;
@@ -77,10 +94,18 @@ export const SuspenseList = REACT_SUSPENSE_LIST_TYPE;
7794export { isValidElementType } ;
7895
7996export function isContextConsumer ( object : any ) : boolean {
80- return typeOf ( object ) === REACT_CONSUMER_TYPE ;
97+ if ( enableRenderableContext ) {
98+ return typeOf ( object ) === REACT_CONSUMER_TYPE ;
99+ } else {
100+ return typeOf ( object ) === REACT_CONTEXT_TYPE ;
101+ }
81102}
82103export function isContextProvider ( object : any ) : boolean {
83- return typeOf ( object ) === REACT_CONTEXT_TYPE ;
104+ if ( enableRenderableContext ) {
105+ return typeOf ( object ) === REACT_CONTEXT_TYPE ;
106+ } else {
107+ return typeOf ( object ) === REACT_PROVIDER_TYPE ;
108+ }
84109}
85110export function isElement ( object : any ) : boolean {
86111 return (
0 commit comments