@@ -24,7 +24,7 @@ if (__DEV__) {
24
24
) {
25
25
__REACT_DEVTOOLS_GLOBAL_HOOK__ . registerInternalModuleStart ( new Error ( ) ) ;
26
26
}
27
- var ReactVersion = "18.3.0-www-classic-ab1e0612 " ;
27
+ var ReactVersion = "18.3.0-www-classic-38e30556 " ;
28
28
29
29
// ATTENTION
30
30
// When adding new symbols to this file,
@@ -35,7 +35,9 @@ if (__DEV__) {
35
35
var REACT_FRAGMENT_TYPE = Symbol . for ( "react.fragment" ) ;
36
36
var REACT_STRICT_MODE_TYPE = Symbol . for ( "react.strict_mode" ) ;
37
37
var REACT_PROFILER_TYPE = Symbol . for ( "react.profiler" ) ;
38
- var REACT_PROVIDER_TYPE = Symbol . for ( "react.provider" ) ;
38
+ var REACT_PROVIDER_TYPE = Symbol . for ( "react.provider" ) ; // TODO: Delete with enableRenderableContext
39
+
40
+ var REACT_CONSUMER_TYPE = Symbol . for ( "react.consumer" ) ;
39
41
var REACT_CONTEXT_TYPE = Symbol . for ( "react.context" ) ;
40
42
var REACT_FORWARD_REF_TYPE = Symbol . for ( "react.forward_ref" ) ;
41
43
var REACT_SUSPENSE_TYPE = Symbol . for ( "react.suspense" ) ;
@@ -473,8 +475,8 @@ if (__DEV__) {
473
475
474
476
var enableDebugTracing = dynamicFeatureFlags . enableDebugTracing ,
475
477
enableTransitionTracing = dynamicFeatureFlags . enableTransitionTracing ,
476
- enableAsyncActions = dynamicFeatureFlags . enableAsyncActions ;
477
- // On WWW, false is used for a new modern build.
478
+ enableAsyncActions = dynamicFeatureFlags . enableAsyncActions ,
479
+ enableRenderableContext = dynamicFeatureFlags . enableRenderableContext ; // On WWW, false is used for a new modern build.
478
480
479
481
function getWrappedName ( outerType , innerType , wrapperName ) {
480
482
var displayName = outerType . displayName ;
@@ -556,13 +558,30 @@ if (__DEV__) {
556
558
}
557
559
558
560
switch ( type . $$typeof ) {
561
+ case REACT_PROVIDER_TYPE :
562
+ if ( enableRenderableContext ) {
563
+ return null ;
564
+ } else {
565
+ var provider = type ;
566
+ return getContextName ( provider . _context ) + ".Provider" ;
567
+ }
568
+
559
569
case REACT_CONTEXT_TYPE :
560
570
var context = type ;
561
- return getContextName ( context ) + ".Consumer" ;
562
571
563
- case REACT_PROVIDER_TYPE :
564
- var provider = type ;
565
- return getContextName ( provider . _context ) + ".Provider" ;
572
+ if ( enableRenderableContext ) {
573
+ return getContextName ( context ) + ".Provider" ;
574
+ } else {
575
+ return getContextName ( context ) + ".Consumer" ;
576
+ }
577
+
578
+ case REACT_CONSUMER_TYPE :
579
+ if ( enableRenderableContext ) {
580
+ var consumer = type ;
581
+ return getContextName ( consumer . _context ) + ".Consumer" ;
582
+ } else {
583
+ return null ;
584
+ }
566
585
567
586
case REACT_FORWARD_REF_TYPE :
568
587
return getWrappedName ( type , type . render , "ForwardRef" ) ;
@@ -1022,8 +1041,9 @@ if (__DEV__) {
1022
1041
if (
1023
1042
type . $$typeof === REACT_LAZY_TYPE ||
1024
1043
type . $$typeof === REACT_MEMO_TYPE ||
1025
- type . $$typeof === REACT_PROVIDER_TYPE ||
1026
1044
type . $$typeof === REACT_CONTEXT_TYPE ||
1045
+ ( ! enableRenderableContext && type . $$typeof === REACT_PROVIDER_TYPE ) ||
1046
+ ( enableRenderableContext && type . $$typeof === REACT_CONSUMER_TYPE ) ||
1027
1047
type . $$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
1028
1048
// types supported by any Flight configuration anywhere since
1029
1049
// we don't know which Flight build this will end up being used
@@ -2472,98 +2492,71 @@ if (__DEV__) {
2472
2492
Provider : null ,
2473
2493
Consumer : null
2474
2494
} ;
2475
- context . Provider = {
2476
- $$typeof : REACT_PROVIDER_TYPE ,
2477
- _context : context
2478
- } ;
2479
- var hasWarnedAboutUsingNestedContextConsumers = false ;
2480
- var hasWarnedAboutUsingConsumerProvider = false ;
2481
- var hasWarnedAboutDisplayNameOnConsumer = false ;
2482
2495
2483
- {
2484
- // A separate object, but proxies back to the original context object for
2485
- // backwards compatibility. It has a different $$typeof, so we can properly
2486
- // warn for the incorrect usage of Context as a Consumer.
2487
- var Consumer = {
2488
- $$typeof : REACT_CONTEXT_TYPE ,
2496
+ if ( enableRenderableContext ) {
2497
+ context . Provider = context ;
2498
+ context . Consumer = {
2499
+ $$typeof : REACT_CONSUMER_TYPE ,
2489
2500
_context : context
2490
- } ; // $FlowFixMe[prop-missing]: Flow complains about not setting a value, which is intentional here
2491
-
2492
- Object . defineProperties ( Consumer , {
2493
- Provider : {
2494
- get : function ( ) {
2495
- if ( ! hasWarnedAboutUsingConsumerProvider ) {
2496
- hasWarnedAboutUsingConsumerProvider = true ;
2501
+ } ;
2502
+ } else {
2503
+ context . Provider = {
2504
+ $$typeof : REACT_PROVIDER_TYPE ,
2505
+ _context : context
2506
+ } ;
2497
2507
2498
- error (
2499
- "Rendering <Context.Consumer.Provider> is not supported and will be removed in " +
2500
- "a future major release. Did you mean to render <Context.Provider> instead?"
2501
- ) ;
2508
+ {
2509
+ var Consumer = {
2510
+ $$typeof : REACT_CONTEXT_TYPE ,
2511
+ _context : context
2512
+ } ;
2513
+ Object . defineProperties ( Consumer , {
2514
+ Provider : {
2515
+ get : function ( ) {
2516
+ return context . Provider ;
2517
+ } ,
2518
+ set : function ( _Provider ) {
2519
+ context . Provider = _Provider ;
2502
2520
}
2503
-
2504
- return context . Provider ;
2505
2521
} ,
2506
- set : function ( _Provider ) {
2507
- context . Provider = _Provider ;
2508
- }
2509
- } ,
2510
- _currentValue : {
2511
- get : function ( ) {
2512
- return context . _currentValue ;
2513
- } ,
2514
- set : function ( _currentValue ) {
2515
- context . _currentValue = _currentValue ;
2516
- }
2517
- } ,
2518
- _currentValue2 : {
2519
- get : function ( ) {
2520
- return context . _currentValue2 ;
2522
+ _currentValue : {
2523
+ get : function ( ) {
2524
+ return context . _currentValue ;
2525
+ } ,
2526
+ set : function ( _currentValue ) {
2527
+ context . _currentValue = _currentValue ;
2528
+ }
2521
2529
} ,
2522
- set : function ( _currentValue2 ) {
2523
- context . _currentValue2 = _currentValue2 ;
2524
- }
2525
- } ,
2526
- _threadCount : {
2527
- get : function ( ) {
2528
- return context . _threadCount ;
2530
+ _currentValue2 : {
2531
+ get : function ( ) {
2532
+ return context . _currentValue2 ;
2533
+ } ,
2534
+ set : function ( _currentValue2 ) {
2535
+ context . _currentValue2 = _currentValue2 ;
2536
+ }
2529
2537
} ,
2530
- set : function ( _threadCount ) {
2531
- context . _threadCount = _threadCount ;
2532
- }
2533
- } ,
2534
- Consumer : {
2535
- get : function ( ) {
2536
- if ( ! hasWarnedAboutUsingNestedContextConsumers ) {
2537
- hasWarnedAboutUsingNestedContextConsumers = true ;
2538
-
2539
- error (
2540
- "Rendering <Context.Consumer.Consumer> is not supported and will be removed in " +
2541
- "a future major release. Did you mean to render <Context.Consumer> instead?"
2542
- ) ;
2538
+ _threadCount : {
2539
+ get : function ( ) {
2540
+ return context . _threadCount ;
2541
+ } ,
2542
+ set : function ( _threadCount ) {
2543
+ context . _threadCount = _threadCount ;
2543
2544
}
2544
-
2545
- return context . Consumer ;
2546
- }
2547
- } ,
2548
- displayName : {
2549
- get : function ( ) {
2550
- return context . displayName ;
2551
2545
} ,
2552
- set : function ( displayName ) {
2553
- if ( ! hasWarnedAboutDisplayNameOnConsumer ) {
2554
- warn (
2555
- "Setting `displayName` on Context.Consumer has no effect. " +
2556
- "You should set it directly on the context with Context.displayName = '%s'." ,
2557
- displayName
2558
- ) ;
2559
-
2560
- hasWarnedAboutDisplayNameOnConsumer = true ;
2546
+ Consumer : {
2547
+ get : function ( ) {
2548
+ return context . Consumer ;
2561
2549
}
2550
+ } ,
2551
+ displayName : {
2552
+ get : function ( ) {
2553
+ return context . displayName ;
2554
+ } ,
2555
+ set : function ( displayName ) { }
2562
2556
}
2563
- }
2564
- } ) ; // $FlowFixMe[prop-missing]: Flow complains about missing properties because it doesn't understand defineProperty
2565
-
2566
- context . Consumer = Consumer ;
2557
+ } ) ;
2558
+ context . Consumer = Consumer ;
2559
+ }
2567
2560
}
2568
2561
2569
2562
{
@@ -2910,22 +2903,11 @@ if (__DEV__) {
2910
2903
var dispatcher = resolveDispatcher ( ) ;
2911
2904
2912
2905
{
2913
- // TODO: add a more generic warning for invalid values.
2914
- if ( Context . _context !== undefined ) {
2915
- var realContext = Context . _context ; // Don't deduplicate because this legitimately causes bugs
2916
- // and nobody should be using this in existing code.
2917
-
2918
- if ( realContext . Consumer === Context ) {
2919
- error (
2920
- "Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be " +
2921
- "removed in a future major release. Did you mean to call useContext(Context) instead?"
2922
- ) ;
2923
- } else if ( realContext . Provider === Context ) {
2924
- error (
2925
- "Calling useContext(Context.Provider) is not supported. " +
2926
- "Did you mean to call useContext(Context) instead?"
2927
- ) ;
2928
- }
2906
+ if ( Context . $$typeof === REACT_CONSUMER_TYPE ) {
2907
+ error (
2908
+ "Calling useContext(Context.Consumer) is not supported and will cause bugs. " +
2909
+ "Did you mean to call useContext(Context) instead?"
2910
+ ) ;
2929
2911
}
2930
2912
}
2931
2913
0 commit comments