@@ -37,14 +37,7 @@ import {
37
37
ForceUpdate ,
38
38
} from './ReactUpdateQueue' ;
39
39
import { NoWork } from './ReactFiberExpirationTime' ;
40
- import {
41
- cacheContext ,
42
- getMaskedContext ,
43
- getUnmaskedContext ,
44
- isContextConsumer ,
45
- hasContextChanged ,
46
- emptyContextObject ,
47
- } from './ReactFiberContext' ;
40
+ // TODO: Maybe we can remove this?
48
41
import {
49
42
requestCurrentTime ,
50
43
computeExpirationForFiber ,
@@ -468,14 +461,10 @@ function adoptClassInstance(workInProgress: Fiber, instance: any): void {
468
461
function constructClassInstance (
469
462
workInProgress : Fiber ,
470
463
props : any ,
464
+ legacyContext : Object ,
471
465
renderExpirationTime : ExpirationTime ,
472
466
) : any {
473
467
const ctor = workInProgress . type ;
474
- const unmaskedContext = getUnmaskedContext ( workInProgress ) ;
475
- const needsContext = isContextConsumer ( workInProgress ) ;
476
- const context = needsContext
477
- ? getMaskedContext ( workInProgress , unmaskedContext )
478
- : emptyContextObject ;
479
468
480
469
// Instantiate twice to help detect side-effects.
481
470
if ( __DEV__ ) {
@@ -484,11 +473,11 @@ function constructClassInstance(
484
473
( debugRenderPhaseSideEffectsForStrictMode &&
485
474
workInProgress . mode & StrictMode )
486
475
) {
487
- new ctor ( props , context ) ; // eslint-disable-line no-new
476
+ new ctor ( props , legacyContext ) ; // eslint-disable-line no-new
488
477
}
489
478
}
490
479
491
- const instance = new ctor ( props , context ) ;
480
+ const instance = new ctor ( props , legacyContext ) ;
492
481
const state = ( workInProgress . memoizedState =
493
482
instance . state !== null && instance . state !== undefined
494
483
? instance . state
@@ -577,12 +566,6 @@ function constructClassInstance(
577
566
}
578
567
}
579
568
580
- // Cache unmasked context so we can avoid recreating masked context unless necessary.
581
- // ReactFiberContext usually updates this cache but can't for newly-created instances.
582
- if ( needsContext ) {
583
- cacheContext ( workInProgress , unmaskedContext , context ) ;
584
- }
585
-
586
569
return instance ;
587
570
}
588
571
@@ -650,6 +633,7 @@ function callComponentWillReceiveProps(
650
633
// Invokes the mount life-cycles on a previously never rendered instance.
651
634
function mountClassInstance (
652
635
workInProgress : Fiber ,
636
+ legacyContext : Object ,
653
637
renderExpirationTime : ExpirationTime ,
654
638
) : void {
655
639
const ctor = workInProgress . type ;
@@ -660,12 +644,11 @@ function mountClassInstance(
660
644
661
645
const instance = workInProgress . stateNode ;
662
646
const props = workInProgress . pendingProps ;
663
- const unmaskedContext = getUnmaskedContext ( workInProgress ) ;
664
647
665
648
instance . props = props ;
666
649
instance . state = workInProgress . memoizedState ;
667
650
instance . refs = emptyRefsObject ;
668
- instance . context = getMaskedContext ( workInProgress , unmaskedContext ) ;
651
+ instance . context = legacyContext ;
669
652
670
653
if ( __DEV__ ) {
671
654
if ( workInProgress . mode & StrictMode ) {
@@ -737,6 +720,7 @@ function mountClassInstance(
737
720
738
721
function resumeMountClassInstance (
739
722
workInProgress : Fiber ,
723
+ nextLegacyContext : Object ,
740
724
renderExpirationTime : ExpirationTime ,
741
725
) : boolean {
742
726
const ctor = workInProgress . type ;
@@ -747,13 +731,8 @@ function resumeMountClassInstance(
747
731
instance . props = oldProps ;
748
732
749
733
const oldContext = instance . context ;
750
- const nextLegacyUnmaskedContext = getUnmaskedContext ( workInProgress ) ;
751
- const nextLegacyContext = getMaskedContext (
752
- workInProgress ,
753
- nextLegacyUnmaskedContext ,
754
- ) ;
755
734
756
- const hasPendingNewContext = checkForPendingContext (
735
+ const hasPendingContext = checkForPendingContext (
757
736
workInProgress ,
758
737
renderExpirationTime ,
759
738
) ;
@@ -802,8 +781,7 @@ function resumeMountClassInstance(
802
781
if (
803
782
oldProps === newProps &&
804
783
oldState === newState &&
805
- ! hasContextChanged ( ) &&
806
- ! hasPendingNewContext &&
784
+ ! hasPendingContext &&
807
785
! checkHasForceUpdateAfterProcessing ( )
808
786
) {
809
787
// If an update was already in progress, we should schedule an Update
@@ -825,7 +803,6 @@ function resumeMountClassInstance(
825
803
826
804
const shouldUpdate =
827
805
checkHasForceUpdateAfterProcessing ( ) ||
828
- hasPendingNewContext ||
829
806
checkShouldComponentUpdate (
830
807
workInProgress ,
831
808
oldProps ,
@@ -881,6 +858,7 @@ function resumeMountClassInstance(
881
858
function updateClassInstance (
882
859
current : Fiber ,
883
860
workInProgress : Fiber ,
861
+ nextLegacyContext : Object ,
884
862
renderExpirationTime : ExpirationTime ,
885
863
) : boolean {
886
864
const ctor = workInProgress . type ;
@@ -891,13 +869,8 @@ function updateClassInstance(
891
869
instance . props = oldProps ;
892
870
893
871
const oldContext = instance . context ;
894
- const nextLegacyUnmaskedContext = getUnmaskedContext ( workInProgress ) ;
895
- const nextLegacyContext = getMaskedContext (
896
- workInProgress ,
897
- nextLegacyUnmaskedContext ,
898
- ) ;
899
872
900
- const hasPendingNewContext = checkForPendingContext (
873
+ const hasPendingContext = checkForPendingContext (
901
874
workInProgress ,
902
875
renderExpirationTime ,
903
876
) ;
@@ -947,8 +920,7 @@ function updateClassInstance(
947
920
if (
948
921
oldProps === newProps &&
949
922
oldState === newState &&
950
- ! hasContextChanged ( ) &&
951
- ! hasPendingNewContext &&
923
+ ! hasPendingContext &&
952
924
! checkHasForceUpdateAfterProcessing ( )
953
925
) {
954
926
// If an update was already in progress, we should schedule an Update
@@ -983,7 +955,6 @@ function updateClassInstance(
983
955
984
956
const shouldUpdate =
985
957
checkHasForceUpdateAfterProcessing ( ) ||
986
- hasPendingNewContext ||
987
958
checkShouldComponentUpdate (
988
959
workInProgress ,
989
960
oldProps ,
0 commit comments