@@ -100,7 +100,6 @@ import {
100100 enableProfilerCommitHooks ,
101101 enableProfilerTimer ,
102102 enableScopeAPI ,
103- enableCache ,
104103 enableLazyContextPropagation ,
105104 enableSchedulingProfiler ,
106105 enableTransitionTracing ,
@@ -714,12 +713,10 @@ function updateOffscreenComponent(
714713 cachePool : null ,
715714 } ;
716715 workInProgress . memoizedState = nextState ;
717- if ( enableCache ) {
718- // push the cache pool even though we're going to bail out
719- // because otherwise there'd be a context mismatch
720- if ( current !== null ) {
721- pushTransition ( workInProgress , null , null ) ;
722- }
716+ // push the cache pool even though we're going to bail out
717+ // because otherwise there'd be a context mismatch
718+ if ( current !== null ) {
719+ pushTransition ( workInProgress , null , null ) ;
723720 }
724721 reuseHiddenContextOnStack ( workInProgress ) ;
725722 pushOffscreenSuspenseHandler ( workInProgress ) ;
@@ -753,7 +750,7 @@ function updateOffscreenComponent(
753750 cachePool : null ,
754751 } ;
755752 workInProgress . memoizedState = nextState ;
756- if ( enableCache && current !== null ) {
753+ if ( current !== null ) {
757754 // If the render that spawned this one accessed the cache pool, resume
758755 // using the same cache. Unless the parent changed, since that means
759756 // there was a refresh.
@@ -776,12 +773,10 @@ function updateOffscreenComponent(
776773 if ( prevState !== null ) {
777774 // We're going from hidden -> visible.
778775 let prevCachePool = null ;
779- if ( enableCache ) {
780- // If the render that spawned this one accessed the cache pool, resume
781- // using the same cache. Unless the parent changed, since that means
782- // there was a refresh.
783- prevCachePool = prevState . cachePool ;
784- }
776+ // If the render that spawned this one accessed the cache pool, resume
777+ // using the same cache. Unless the parent changed, since that means
778+ // there was a refresh.
779+ prevCachePool = prevState . cachePool ;
785780
786781 let transitions = null ;
787782 if ( enableTransitionTracing ) {
@@ -806,13 +801,11 @@ function updateOffscreenComponent(
806801 // special to do. Need to push to the stack regardless, though, to avoid
807802 // a push/pop misalignment.
808803
809- if ( enableCache ) {
810- // If the render that spawned this one accessed the cache pool, resume
811- // using the same cache. Unless the parent changed, since that means
812- // there was a refresh.
813- if ( current !== null ) {
814- pushTransition ( workInProgress , null , null ) ;
815- }
804+ // If the render that spawned this one accessed the cache pool, resume
805+ // using the same cache. Unless the parent changed, since that means
806+ // there was a refresh.
807+ if ( current !== null ) {
808+ pushTransition ( workInProgress , null , null ) ;
816809 }
817810
818811 // We're about to bail out, but we need to push this to the stack anyway
@@ -835,15 +828,13 @@ function deferHiddenOffscreenComponent(
835828 const nextState : OffscreenState = {
836829 baseLanes : nextBaseLanes ,
837830 // Save the cache pool so we can resume later.
838- cachePool : enableCache ? getOffscreenDeferredCache ( ) : null ,
831+ cachePool : getOffscreenDeferredCache ( ) ,
839832 } ;
840833 workInProgress . memoizedState = nextState ;
841- if ( enableCache ) {
842- // push the cache pool even though we're going to bail out
843- // because otherwise there'd be a context mismatch
844- if ( current !== null ) {
845- pushTransition ( workInProgress , null , null ) ;
846- }
834+ // push the cache pool even though we're going to bail out
835+ // because otherwise there'd be a context mismatch
836+ if ( current !== null ) {
837+ pushTransition ( workInProgress , null , null ) ;
847838 }
848839
849840 // We're about to bail out, but we need to push this to the stack anyway
@@ -876,10 +867,6 @@ function updateCacheComponent(
876867 workInProgress : Fiber ,
877868 renderLanes : Lanes ,
878869) {
879- if ( ! enableCache ) {
880- return null ;
881- }
882-
883870 prepareToReadContext ( workInProgress , renderLanes ) ;
884871 const parentCache = readContext ( CacheContext ) ;
885872
@@ -1480,13 +1467,11 @@ function updateHostRoot(
14801467 pushRootMarkerInstance ( workInProgress ) ;
14811468 }
14821469
1483- if ( enableCache ) {
1484- const nextCache : Cache = nextState . cache ;
1485- pushCacheProvider ( workInProgress , nextCache ) ;
1486- if ( nextCache !== prevState . cache ) {
1487- // The root cache refreshed.
1488- propagateContextChange ( workInProgress , CacheContext , renderLanes ) ;
1489- }
1470+ const nextCache : Cache = nextState . cache ;
1471+ pushCacheProvider ( workInProgress , nextCache ) ;
1472+ if ( nextCache !== prevState . cache ) {
1473+ // The root cache refreshed.
1474+ propagateContextChange ( workInProgress , CacheContext , renderLanes ) ;
14901475 }
14911476
14921477 // This would ideally go inside processUpdateQueue, but because it suspends,
@@ -1990,28 +1975,26 @@ function updateSuspenseOffscreenState(
19901975 renderLanes : Lanes ,
19911976) : OffscreenState {
19921977 let cachePool : SpawnedCachePool | null = null ;
1993- if ( enableCache ) {
1994- const prevCachePool : SpawnedCachePool | null = prevOffscreenState . cachePool ;
1995- if ( prevCachePool !== null ) {
1996- const parentCache = isPrimaryRenderer
1997- ? CacheContext . _currentValue
1998- : CacheContext . _currentValue2 ;
1999- if ( prevCachePool . parent !== parentCache ) {
2000- // Detected a refresh in the parent. This overrides any previously
2001- // suspended cache.
2002- cachePool = {
2003- parent : parentCache ,
2004- pool : parentCache ,
2005- } ;
2006- } else {
2007- // We can reuse the cache from last time. The only thing that would have
2008- // overridden it is a parent refresh, which we checked for above.
2009- cachePool = prevCachePool ;
2010- }
1978+ const prevCachePool : SpawnedCachePool | null = prevOffscreenState . cachePool ;
1979+ if ( prevCachePool !== null ) {
1980+ const parentCache = isPrimaryRenderer
1981+ ? CacheContext . _currentValue
1982+ : CacheContext . _currentValue2 ;
1983+ if ( prevCachePool . parent !== parentCache ) {
1984+ // Detected a refresh in the parent. This overrides any previously
1985+ // suspended cache.
1986+ cachePool = {
1987+ parent : parentCache ,
1988+ pool : parentCache ,
1989+ } ;
20111990 } else {
2012- // If there's no previous cache pool, grab the current one.
2013- cachePool = getSuspendedCache ( ) ;
1991+ // We can reuse the cache from last time. The only thing that would have
1992+ // overridden it is a parent refresh, which we checked for above.
1993+ cachePool = prevCachePool ;
20141994 }
1995+ } else {
1996+ // If there's no previous cache pool, grab the current one.
1997+ cachePool = getSuspendedCache ( ) ;
20151998 }
20161999 return {
20172000 baseLanes : mergeLanes ( prevOffscreenState . baseLanes , renderLanes ) ,
@@ -3599,7 +3582,7 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
35993582 // the begin phase. There's still some bookkeeping we that needs to be done
36003583 // in this optimized path, mostly pushing stuff onto the stack.
36013584 switch ( workInProgress . tag ) {
3602- case HostRoot :
3585+ case HostRoot : {
36033586 pushHostRootContext ( workInProgress ) ;
36043587 const root : FiberRoot = workInProgress . stateNode ;
36053588 pushRootTransition ( workInProgress , root , renderLanes ) ;
@@ -3608,12 +3591,11 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
36083591 pushRootMarkerInstance ( workInProgress ) ;
36093592 }
36103593
3611- if ( enableCache ) {
3612- const cache : Cache = current . memoizedState . cache ;
3613- pushCacheProvider ( workInProgress , cache ) ;
3614- }
3594+ const cache : Cache = current . memoizedState . cache ;
3595+ pushCacheProvider ( workInProgress , cache ) ;
36153596 resetHydrationState ( ) ;
36163597 break ;
3598+ }
36173599 case HostSingleton :
36183600 case HostComponent :
36193601 pushHostContext ( workInProgress ) ;
@@ -3795,10 +3777,8 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
37953777 return updateOffscreenComponent ( current , workInProgress , renderLanes ) ;
37963778 }
37973779 case CacheComponent: {
3798- if ( enableCache ) {
3799- const cache : Cache = current . memoizedState . cache ;
3800- pushCacheProvider ( workInProgress , cache ) ;
3801- }
3780+ const cache : Cache = current . memoizedState . cache ;
3781+ pushCacheProvider ( workInProgress , cache ) ;
38023782 break ;
38033783 }
38043784 case TracingMarkerComponent: {
@@ -4085,10 +4065,7 @@ function beginWork(
40854065 break ;
40864066 }
40874067 case CacheComponent : {
4088- if ( enableCache ) {
4089- return updateCacheComponent ( current , workInProgress , renderLanes ) ;
4090- }
4091- break ;
4068+ return updateCacheComponent ( current , workInProgress , renderLanes ) ;
40924069 }
40934070 case TracingMarkerComponent : {
40944071 if ( enableTransitionTracing ) {
0 commit comments