@@ -460,10 +460,11 @@ export function getInternalReactConstants(version: string): {
460460      IncompleteFunctionComponent : 28 , 
461461      IndeterminateComponent : 2 ,  // removed in 19.0.0 
462462      LazyComponent : 16 , 
463-       LegacyHiddenComponent : 23 , 
463+       LegacyHiddenComponent : 23 ,   // Does not exist in 18+ OSS but exists in fb builds 
464464      MemoComponent : 14 , 
465465      Mode : 8 , 
466-       OffscreenComponent : 22 ,  // Experimental 
466+       OffscreenComponent : 22 ,  // Experimental - This is technically in 18 but we don't 
467+       // want to fork again so we're adding it here instead 
467468      Profiler : 12 , 
468469      ScopeComponent : 21 ,  // Experimental 
469470      SimpleMemoComponent : 15 , 
@@ -3057,13 +3058,23 @@ export function attach(
30573058    } 
30583059  } 
30593060
3061+   function isHiddenOffscreen(fiber: Fiber): boolean { 
3062+     switch (fiber.tag) { 
3063+       case LegacyHiddenComponent: 
3064+       // fallthrough since all published implementations currently implement the same state as Offscreen. 
3065+       case OffscreenComponent: 
3066+         return fiber.memoizedState !== null; 
3067+       default: 
3068+         return false; 
3069+     } 
3070+   } 
3071+ 
30603072  function unmountRemainingChildren() { 
30613073    if ( 
30623074      reconcilingParent !== null && 
30633075      (reconcilingParent.kind === FIBER_INSTANCE || 
30643076        reconcilingParent.kind === FILTERED_FIBER_INSTANCE) && 
3065-       reconcilingParent.data.tag === OffscreenComponent && 
3066-       reconcilingParent.data.memoizedState !== null && 
3077+       isHiddenOffscreen(reconcilingParent.data) && 
30673078      !isInDisconnectedSubtree 
30683079    ) { 
30693080      // This is a hidden offscreen, we need to execute this in the context of a disconnected subtree. 
@@ -3170,8 +3181,7 @@ export function attach(
31703181      if ( 
31713182        (parent.kind === FIBER_INSTANCE || 
31723183          parent.kind === FILTERED_FIBER_INSTANCE) && 
3173-         parent.data.tag === OffscreenComponent && 
3174-         parent.data.memoizedState !== null 
3184+         isHiddenOffscreen(parent.data) 
31753185      ) { 
31763186        // We're inside a hidden offscreen Fiber. We're in a disconnected tree. 
31773187        return; 
@@ -3819,7 +3829,9 @@ export function attach(
38193829      (reconcilingParent !== null && 
38203830        reconcilingParent.kind === VIRTUAL_INSTANCE) || 
38213831      fiber.tag === SuspenseComponent || 
3822-       fiber.tag === OffscreenComponent // Use to keep resuspended instances alive inside a SuspenseComponent. 
3832+       // Use to keep resuspended instances alive inside a SuspenseComponent. 
3833+       fiber.tag === OffscreenComponent || 
3834+       fiber.tag === LegacyHiddenComponent 
38233835    ) { 
38243836      // If the parent is a Virtual Instance and we filtered this Fiber we include a 
38253837      // hidden node. We also include this if it's a Suspense boundary so we can track those 
@@ -3939,7 +3951,7 @@ export function attach(
39393951        trackDebugInfoFromHostComponent(nearestInstance, fiber); 
39403952      } 
39413953
3942-       if (fiber.tag === OffscreenComponent && fiber.memoizedState !== null ) { 
3954+       if (isHiddenOffscreen( fiber) ) { 
39433955        // If an Offscreen component is hidden, mount its children as disconnected. 
39443956        const stashedDisconnected = isInDisconnectedSubtree; 
39453957        isInDisconnectedSubtree = true; 
@@ -4261,7 +4273,7 @@ export function attach(
42614273    while (child !== null) { 
42624274      if (child.kind === FILTERED_FIBER_INSTANCE) { 
42634275        const fiber = child.data; 
4264-         if (fiber.tag === OffscreenComponent && fiber.memoizedState !== null ) { 
4276+         if (isHiddenOffscreen( fiber) ) { 
42654277          // The children of this Offscreen are hidden so they don't get added. 
42664278        } else { 
42674279          addUnfilteredChildrenIDs(child, nextChildren); 
@@ -4888,9 +4900,8 @@ export function attach(
48884900      const nextDidTimeOut = 
48894901        isLegacySuspense && nextFiber.memoizedState !== null; 
48904902
4891-       const isOffscreen = nextFiber.tag === OffscreenComponent; 
4892-       const prevWasHidden = isOffscreen && prevFiber.memoizedState !== null; 
4893-       const nextIsHidden = isOffscreen && nextFiber.memoizedState !== null; 
4903+       const prevWasHidden = isHiddenOffscreen(prevFiber); 
4904+       const nextIsHidden = isHiddenOffscreen(nextFiber); 
48944905
48954906      if (isLegacySuspense) { 
48964907        if ( 
@@ -5245,8 +5256,7 @@ export function attach(
52455256      if ( 
52465257        (child.kind === FIBER_INSTANCE || 
52475258          child.kind === FILTERED_FIBER_INSTANCE) && 
5248-         child.data.tag === OffscreenComponent && 
5249-         child.data.memoizedState !== null 
5259+         isHiddenOffscreen(child.data) 
52505260      ) { 
52515261        // This instance's children are already disconnected. 
52525262      } else { 
@@ -5275,8 +5285,7 @@ export function attach(
52755285      if ( 
52765286        (child.kind === FIBER_INSTANCE || 
52775287          child.kind === FILTERED_FIBER_INSTANCE) && 
5278-         child.data.tag === OffscreenComponent && 
5279-         child.data.memoizedState !== null 
5288+         isHiddenOffscreen(child.data) 
52805289      ) { 
52815290        // This instance's children should remain disconnected. 
52825291      } else { 
0 commit comments