@@ -18,20 +18,15 @@ import type {
1818} from './ReactFiberConfig' ;
1919import type { Fiber , FiberRoot } from './ReactInternalTypes' ;
2020import type { Lanes } from './ReactFiberLane' ;
21- import {
22- includesOnlyViewTransitionEligibleLanes ,
23- SyncLane ,
24- } from './ReactFiberLane' ;
21+ import { includesOnlyViewTransitionEligibleLanes } from './ReactFiberLane' ;
2522import type { SuspenseState , RetryQueue } from './ReactFiberSuspenseComponent' ;
2623import type { UpdateQueue } from './ReactFiberClassUpdateQueue' ;
2724import type { FunctionComponentUpdateQueue } from './ReactFiberHooks' ;
2825import type { Wakeable } from 'shared/ReactTypes' ;
29- import { isOffscreenManual } from './ReactFiberActivityComponent' ;
3026import type {
3127 OffscreenState ,
3228 OffscreenInstance ,
3329 OffscreenQueue ,
34- OffscreenProps ,
3530} from './ReactFiberActivityComponent' ;
3631import type { Cache } from './ReactFiberCacheComponent' ;
3732import type { RootState } from './ReactFiberRoot' ;
@@ -194,15 +189,12 @@ import {releaseCache, retainCache} from './ReactFiberCacheComponent';
194189import { clearTransitionsForLanes } from './ReactFiberLane' ;
195190import {
196191 OffscreenVisible ,
197- OffscreenDetached ,
198192 OffscreenPassiveEffectsConnected ,
199193} from './ReactFiberActivityComponent' ;
200194import {
201195 TransitionRoot ,
202196 TransitionTracingMarker ,
203197} from './ReactFiberTracingMarkerComponent' ;
204- import { scheduleUpdateOnFiber } from './ReactFiberWorkLoop' ;
205- import { enqueueConcurrentRenderForLane } from './ReactFiberConcurrentUpdates' ;
206198import {
207199 commitHookLayoutEffects ,
208200 commitHookLayoutUnmountEffects ,
@@ -742,14 +734,6 @@ function commitLayoutEffectOnFiber(
742734 committedLanes ,
743735 ) ;
744736 }
745- if ( flags & Ref ) {
746- const props : OffscreenProps = finishedWork . memoizedProps ;
747- if ( props . mode === 'manual' ) {
748- safelyAttachRef ( finishedWork , finishedWork . return ) ;
749- } else {
750- safelyDetachRef ( finishedWork , finishedWork . return ) ;
751- }
752- }
753737 break ;
754738 }
755739 case ViewTransitionComponent : {
@@ -1538,9 +1522,6 @@ function commitDeletionEffectsOnFiber(
15381522 return ;
15391523 }
15401524 case OffscreenComponent : {
1541- if ( ! offscreenSubtreeWasHidden ) {
1542- safelyDetachRef ( deletedFiber , nearestMountedAncestor ) ;
1543- }
15441525 if ( disableLegacyMode || deletedFiber . mode & ConcurrentMode ) {
15451526 // If this offscreen component is hidden, we already unmounted it. Before
15461527 // deleting the children, track that it's already unmounted so that we
@@ -1672,48 +1653,6 @@ function getRetryCache(finishedWork: Fiber) {
16721653 }
16731654}
16741655
1675- export function detachOffscreenInstance ( instance : OffscreenInstance ) : void {
1676- const fiber = instance . _current ;
1677- if ( fiber === null ) {
1678- throw new Error (
1679- 'Calling Offscreen.detach before instance handle has been set.' ,
1680- ) ;
1681- }
1682-
1683- if ( ( instance . _pendingVisibility & OffscreenDetached ) !== NoFlags ) {
1684- // The instance is already detached, this is a noop.
1685- return ;
1686- }
1687-
1688- // TODO: There is an opportunity to optimise this by not entering commit phase
1689- // and unmounting effects directly.
1690- const root = enqueueConcurrentRenderForLane ( fiber , SyncLane ) ;
1691- if ( root !== null ) {
1692- instance . _pendingVisibility |= OffscreenDetached ;
1693- scheduleUpdateOnFiber ( root , fiber , SyncLane ) ;
1694- }
1695- }
1696-
1697- export function attachOffscreenInstance ( instance : OffscreenInstance ) : void {
1698- const fiber = instance . _current ;
1699- if ( fiber === null ) {
1700- throw new Error (
1701- 'Calling Offscreen.detach before instance handle has been set.' ,
1702- ) ;
1703- }
1704-
1705- if ( ( instance . _pendingVisibility & OffscreenDetached ) === NoFlags ) {
1706- // The instance is already attached, this is a noop.
1707- return ;
1708- }
1709-
1710- const root = enqueueConcurrentRenderForLane ( fiber , SyncLane ) ;
1711- if ( root !== null ) {
1712- instance . _pendingVisibility &= ~ OffscreenDetached ;
1713- scheduleUpdateOnFiber ( root , fiber , SyncLane ) ;
1714- }
1715- }
1716-
17171656function attachSuspenseRetryListeners (
17181657 finishedWork : Fiber ,
17191658 wakeables : RetryQueue ,
@@ -2181,12 +2120,6 @@ function commitMutationEffectsOnFiber(
21812120 break ;
21822121 }
21832122 case OffscreenComponent : {
2184- if ( flags & Ref ) {
2185- if ( ! offscreenSubtreeWasHidden && current !== null ) {
2186- safelyDetachRef ( current , current . return ) ;
2187- }
2188- }
2189-
21902123 const newState : OffscreenState | null = finishedWork . memoizedState ;
21912124 const isHidden = newState !== null ;
21922125 const wasHidden = current !== null && current . memoizedState !== null ;
@@ -2208,18 +2141,9 @@ function commitMutationEffectsOnFiber(
22082141
22092142 commitReconciliationEffects ( finishedWork , lanes ) ;
22102143
2211- const offscreenInstance : OffscreenInstance = finishedWork . stateNode ;
2212-
2213- // TODO: Add explicit effect flag to set _current.
2214- offscreenInstance . _current = finishedWork ;
2215-
2216- // Offscreen stores pending changes to visibility in `_pendingVisibility`. This is
2217- // to support batching of `attach` and `detach` calls.
2218- offscreenInstance . _visibility &= ~ OffscreenDetached ;
2219- offscreenInstance . _visibility |=
2220- offscreenInstance . _pendingVisibility & OffscreenDetached ;
2221-
22222144 if ( flags & Visibility ) {
2145+ const offscreenInstance : OffscreenInstance = finishedWork . stateNode ;
2146+
22232147 // Track the current state on the Offscreen instance so we can
22242148 // read it during an event
22252149 if ( isHidden ) {
@@ -2250,8 +2174,7 @@ function commitMutationEffectsOnFiber(
22502174 }
22512175 }
22522176
2253- // Offscreen with manual mode manages visibility manually.
2254- if ( supportsMutation && ! isOffscreenManual ( finishedWork ) ) {
2177+ if ( supportsMutation ) {
22552178 // TODO: This needs to run whenever there's an insertion or update
22562179 // inside a hidden Offscreen tree.
22572180 hideOrUnhideAllChildren ( finishedWork , isHidden ) ;
@@ -2667,9 +2590,6 @@ export function disappearLayoutEffects(finishedWork: Fiber) {
26672590 break ;
26682591 }
26692592 case OffscreenComponent : {
2670- // TODO (Offscreen) Check: flags & RefStatic
2671- safelyDetachRef ( finishedWork , finishedWork . return ) ;
2672-
26732593 const isHidden = finishedWork . memoizedState !== null ;
26742594 if ( isHidden ) {
26752595 // Nested Offscreen tree is already hidden. Don't disappear
0 commit comments