@@ -100,7 +100,6 @@ import {
100100 enableProfilerCommitHooks ,
101101 enableProfilerTimer ,
102102 enableScopeAPI ,
103- enableCache ,
104103 enableLazyContextPropagation ,
105104 enableSchedulingProfiler ,
106105 enableTransitionTracing ,
@@ -712,12 +711,10 @@ function updateOffscreenComponent(
712711 cachePool : null ,
713712 } ;
714713 workInProgress . memoizedState = nextState ;
715- if ( enableCache ) {
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 ) ;
720- }
714+ // push the cache pool even though we're going to bail out
715+ // because otherwise there'd be a context mismatch
716+ if ( current !== null ) {
717+ pushTransition ( workInProgress , null , null ) ;
721718 }
722719 reuseHiddenContextOnStack ( workInProgress ) ;
723720 pushOffscreenSuspenseHandler ( workInProgress ) ;
@@ -751,7 +748,7 @@ function updateOffscreenComponent(
751748 cachePool : null ,
752749 } ;
753750 workInProgress . memoizedState = nextState ;
754- if ( enableCache && current !== null ) {
751+ if ( current !== null ) {
755752 // If the render that spawned this one accessed the cache pool, resume
756753 // using the same cache. Unless the parent changed, since that means
757754 // there was a refresh.
@@ -774,12 +771,10 @@ function updateOffscreenComponent(
774771 if ( prevState !== null ) {
775772 // We're going from hidden -> visible.
776773 let prevCachePool = null ;
777- if ( enableCache ) {
778- // If the render that spawned this one accessed the cache pool, resume
779- // using the same cache. Unless the parent changed, since that means
780- // there was a refresh.
781- prevCachePool = prevState . cachePool ;
782- }
774+ // If the render that spawned this one accessed the cache pool, resume
775+ // using the same cache. Unless the parent changed, since that means
776+ // there was a refresh.
777+ prevCachePool = prevState . cachePool ;
783778
784779 let transitions = null ;
785780 if ( enableTransitionTracing ) {
@@ -804,13 +799,11 @@ function updateOffscreenComponent(
804799 // special to do. Need to push to the stack regardless, though, to avoid
805800 // a push/pop misalignment.
806801
807- if ( enableCache ) {
808- // If the render that spawned this one accessed the cache pool, resume
809- // using the same cache. Unless the parent changed, since that means
810- // there was a refresh.
811- if ( current !== null ) {
812- pushTransition ( workInProgress , null , null ) ;
813- }
802+ // If the render that spawned this one accessed the cache pool, resume
803+ // using the same cache. Unless the parent changed, since that means
804+ // there was a refresh.
805+ if ( current !== null ) {
806+ pushTransition ( workInProgress , null , null ) ;
814807 }
815808
816809 // We're about to bail out, but we need to push this to the stack anyway
@@ -833,15 +826,13 @@ function deferHiddenOffscreenComponent(
833826 const nextState : OffscreenState = {
834827 baseLanes : nextBaseLanes ,
835828 // Save the cache pool so we can resume later.
836- cachePool : enableCache ? getOffscreenDeferredCache ( ) : null ,
829+ cachePool : getOffscreenDeferredCache ( ) ,
837830 } ;
838831 workInProgress . memoizedState = nextState ;
839- if ( enableCache ) {
840- // push the cache pool even though we're going to bail out
841- // because otherwise there'd be a context mismatch
842- if ( current !== null ) {
843- pushTransition ( workInProgress , null , null ) ;
844- }
832+ // push the cache pool even though we're going to bail out
833+ // because otherwise there'd be a context mismatch
834+ if ( current !== null ) {
835+ pushTransition ( workInProgress , null , null ) ;
845836 }
846837
847838 // We're about to bail out, but we need to push this to the stack anyway
@@ -874,10 +865,6 @@ function updateCacheComponent(
874865 workInProgress : Fiber ,
875866 renderLanes : Lanes ,
876867) {
877- if ( ! enableCache ) {
878- return null ;
879- }
880-
881868 prepareToReadContext ( workInProgress , renderLanes ) ;
882869 const parentCache = readContext ( CacheContext ) ;
883870
@@ -1478,13 +1465,11 @@ function updateHostRoot(
14781465 pushRootMarkerInstance ( workInProgress ) ;
14791466 }
14801467
1481- if ( enableCache ) {
1482- const nextCache : Cache = nextState . cache ;
1483- pushCacheProvider ( workInProgress , nextCache ) ;
1484- if ( nextCache !== prevState . cache ) {
1485- // The root cache refreshed.
1486- propagateContextChange ( workInProgress , CacheContext , renderLanes ) ;
1487- }
1468+ const nextCache : Cache = nextState . cache ;
1469+ pushCacheProvider ( workInProgress , nextCache ) ;
1470+ if ( nextCache !== prevState . cache ) {
1471+ // The root cache refreshed.
1472+ propagateContextChange ( workInProgress , CacheContext , renderLanes ) ;
14881473 }
14891474
14901475 // This would ideally go inside processUpdateQueue, but because it suspends,
@@ -1988,28 +1973,26 @@ function updateSuspenseOffscreenState(
19881973 renderLanes : Lanes ,
19891974) : OffscreenState {
19901975 let cachePool : SpawnedCachePool | null = null ;
1991- if ( enableCache ) {
1992- const prevCachePool : SpawnedCachePool | null = prevOffscreenState . cachePool ;
1993- if ( prevCachePool !== null ) {
1994- const parentCache = isPrimaryRenderer
1995- ? CacheContext . _currentValue
1996- : CacheContext . _currentValue2 ;
1997- if ( prevCachePool . parent !== parentCache ) {
1998- // Detected a refresh in the parent. This overrides any previously
1999- // suspended cache.
2000- cachePool = {
2001- parent : parentCache ,
2002- pool : parentCache ,
2003- } ;
2004- } else {
2005- // We can reuse the cache from last time. The only thing that would have
2006- // overridden it is a parent refresh, which we checked for above.
2007- cachePool = prevCachePool ;
2008- }
1976+ const prevCachePool : SpawnedCachePool | null = prevOffscreenState . cachePool ;
1977+ if ( prevCachePool !== null ) {
1978+ const parentCache = isPrimaryRenderer
1979+ ? CacheContext . _currentValue
1980+ : CacheContext . _currentValue2 ;
1981+ if ( prevCachePool . parent !== parentCache ) {
1982+ // Detected a refresh in the parent. This overrides any previously
1983+ // suspended cache.
1984+ cachePool = {
1985+ parent : parentCache ,
1986+ pool : parentCache ,
1987+ } ;
20091988 } else {
2010- // If there's no previous cache pool, grab the current one.
2011- cachePool = getSuspendedCache ( ) ;
1989+ // We can reuse the cache from last time. The only thing that would have
1990+ // overridden it is a parent refresh, which we checked for above.
1991+ cachePool = prevCachePool ;
20121992 }
1993+ } else {
1994+ // If there's no previous cache pool, grab the current one.
1995+ cachePool = getSuspendedCache ( ) ;
20131996 }
20141997 return {
20151998 baseLanes : mergeLanes ( prevOffscreenState . baseLanes , renderLanes ) ,
@@ -3610,10 +3593,8 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
36103593 pushRootMarkerInstance ( workInProgress ) ;
36113594 }
36123595
3613- if ( enableCache ) {
3614- const cache : Cache = current . memoizedState . cache ;
3615- pushCacheProvider ( workInProgress , cache ) ;
3616- }
3596+ const cache : Cache = current . memoizedState . cache ;
3597+ pushCacheProvider ( workInProgress , cache ) ;
36173598 resetHydrationState ( ) ;
36183599 break ;
36193600 case HostSingleton :
@@ -3797,10 +3778,8 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
37973778 return updateOffscreenComponent ( current , workInProgress , renderLanes ) ;
37983779 }
37993780 case CacheComponent: {
3800- if ( enableCache ) {
3801- const cache : Cache = current . memoizedState . cache ;
3802- pushCacheProvider ( workInProgress , cache ) ;
3803- }
3781+ const cache : Cache = current . memoizedState . cache ;
3782+ pushCacheProvider ( workInProgress , cache ) ;
38043783 break ;
38053784 }
38063785 case TracingMarkerComponent: {
@@ -4087,10 +4066,7 @@ function beginWork(
40874066 break ;
40884067 }
40894068 case CacheComponent : {
4090- if ( enableCache ) {
4091- return updateCacheComponent ( current , workInProgress , renderLanes ) ;
4092- }
4093- break ;
4069+ return updateCacheComponent ( current , workInProgress , renderLanes ) ;
40944070 }
40954071 case TracingMarkerComponent : {
40964072 if ( enableTransitionTracing ) {
0 commit comments