Skip to content

Commit 9d3ed27

Browse files
committed
Call cleanup of insertion effects when hidden (#30954)
Insertion effects do not unmount when a subtree is removed while offscreen. Current behavior for an insertion effect is if the component goes - *visible -> removed:* calls insertion effect cleanup - *visible -> offscreen -> removed:* insertion effect cleanup is never called This makes it so we always call insertion effect cleanup when removing the component. Likely also fixes #26670 --------- Co-authored-by: Rick Hanlon <[email protected]> DiffTrain build for [d3d4d3a](d3d4d3a)
1 parent 037b2e3 commit 9d3ed27

34 files changed

+3254
-2504
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
94e4acaa1477e65cac02ba86058cde0afe4c8f1f
1+
d3d4d3a46b014ab0f6edc443c19fcdba09105f20
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
94e4acaa1477e65cac02ba86058cde0afe4c8f1f
1+
d3d4d3a46b014ab0f6edc443c19fcdba09105f20

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ __DEV__ &&
20012001
exports.useTransition = function () {
20022002
return resolveDispatcher().useTransition();
20032003
};
2004-
exports.version = "19.0.0-www-classic-94e4acaa-20240913";
2004+
exports.version = "19.0.0-www-classic-d3d4d3a4-20240913";
20052005
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
20062006
"function" ===
20072007
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ __DEV__ &&
19811981
exports.useTransition = function () {
19821982
return resolveDispatcher().useTransition();
19831983
};
1984-
exports.version = "19.0.0-www-modern-94e4acaa-20240913";
1984+
exports.version = "19.0.0-www-modern-d3d4d3a4-20240913";
19851985
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19861986
"function" ===
19871987
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,4 @@ exports.useSyncExternalStore = function (
665665
exports.useTransition = function () {
666666
return ReactSharedInternals.H.useTransition();
667667
};
668-
exports.version = "19.0.0-www-classic-94e4acaa-20240913";
668+
exports.version = "19.0.0-www-classic-d3d4d3a4-20240913";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,4 @@ exports.useSyncExternalStore = function (
665665
exports.useTransition = function () {
666666
return ReactSharedInternals.H.useTransition();
667667
};
668-
exports.version = "19.0.0-www-modern-94e4acaa-20240913";
668+
exports.version = "19.0.0-www-modern-d3d4d3a4-20240913";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ exports.useSyncExternalStore = function (
669669
exports.useTransition = function () {
670670
return ReactSharedInternals.H.useTransition();
671671
};
672-
exports.version = "19.0.0-www-classic-94e4acaa-20240913";
672+
exports.version = "19.0.0-www-classic-d3d4d3a4-20240913";
673673
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
674674
"function" ===
675675
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ exports.useSyncExternalStore = function (
669669
exports.useTransition = function () {
670670
return ReactSharedInternals.H.useTransition();
671671
};
672-
exports.version = "19.0.0-www-modern-94e4acaa-20240913";
672+
exports.version = "19.0.0-www-modern-d3d4d3a4-20240913";
673673
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
674674
"function" ===
675675
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 97 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9786,9 +9786,7 @@ __DEV__ &&
97869786
markComponentLayoutEffectUnmountStarted(finishedWork)),
97879787
(flags & Insertion) !== NoFlags &&
97889788
(isRunningInsertionEffect = !0),
9789-
runWithFiberInDEV(
9790-
finishedWork,
9791-
callDestroyInDEV,
9789+
safelyCallDestroy(
97929790
finishedWork,
97939791
nearestMountedAncestor,
97949792
destroy
@@ -10028,6 +10026,15 @@ __DEV__ &&
1002810026
}
1002910027
else ref.current = null;
1003010028
}
10029+
function safelyCallDestroy(current, nearestMountedAncestor, destroy) {
10030+
runWithFiberInDEV(
10031+
current,
10032+
callDestroyInDEV,
10033+
current,
10034+
nearestMountedAncestor,
10035+
destroy
10036+
);
10037+
}
1003110038
function commitProfiler(finishedWork, current, commitTime, effectDuration) {
1003210039
var _finishedWork$memoize = finishedWork.memoizedProps,
1003310040
onCommit = _finishedWork$memoize.onCommit;
@@ -10816,54 +10823,95 @@ __DEV__ &&
1081610823
case 11:
1081710824
case 14:
1081810825
case 15:
10819-
if (
10826+
if (enableHiddenSubtreeInsertionEffectCleanup) {
10827+
if (
10828+
((_prevHostParent = deletedFiber.updateQueue),
10829+
null !== _prevHostParent &&
10830+
((_prevHostParent = _prevHostParent.lastEffect),
10831+
null !== _prevHostParent))
10832+
) {
10833+
_prevHostParentIsContainer = _prevHostParent =
10834+
_prevHostParent.next;
10835+
do {
10836+
var tag = _prevHostParentIsContainer.tag,
10837+
inst = _prevHostParentIsContainer.inst,
10838+
destroy = inst.destroy;
10839+
void 0 !== destroy &&
10840+
((tag & Insertion) !== NoFlags
10841+
? ((isRunningInsertionEffect = !0),
10842+
(inst.destroy = void 0),
10843+
safelyCallDestroy(
10844+
deletedFiber,
10845+
nearestMountedAncestor,
10846+
destroy
10847+
),
10848+
(isRunningInsertionEffect = !1))
10849+
: offscreenSubtreeWasHidden ||
10850+
(tag & Layout) === NoFlags ||
10851+
(enableSchedulingProfiler &&
10852+
markComponentLayoutEffectUnmountStarted(deletedFiber),
10853+
shouldProfile(deletedFiber)
10854+
? (startLayoutEffectTimer(),
10855+
(inst.destroy = void 0),
10856+
safelyCallDestroy(
10857+
deletedFiber,
10858+
nearestMountedAncestor,
10859+
destroy
10860+
),
10861+
recordLayoutEffectDuration(deletedFiber))
10862+
: ((inst.destroy = void 0),
10863+
safelyCallDestroy(
10864+
deletedFiber,
10865+
nearestMountedAncestor,
10866+
destroy
10867+
)),
10868+
enableSchedulingProfiler &&
10869+
markComponentLayoutEffectUnmountStopped()));
10870+
_prevHostParentIsContainer = _prevHostParentIsContainer.next;
10871+
} while (_prevHostParentIsContainer !== _prevHostParent);
10872+
}
10873+
} else if (
1082010874
!offscreenSubtreeWasHidden &&
1082110875
((_prevHostParent = deletedFiber.updateQueue),
1082210876
null !== _prevHostParent &&
1082310877
((_prevHostParent = _prevHostParent.lastEffect),
1082410878
null !== _prevHostParent))
1082510879
) {
1082610880
_prevHostParentIsContainer = _prevHostParent = _prevHostParent.next;
10827-
do {
10828-
var tag = _prevHostParentIsContainer.tag,
10829-
inst = _prevHostParentIsContainer.inst,
10830-
destroy = inst.destroy;
10831-
void 0 !== destroy &&
10832-
((tag & Insertion) !== NoFlags
10833-
? ((inst.destroy = void 0),
10834-
runWithFiberInDEV(
10835-
deletedFiber,
10836-
callDestroyInDEV,
10837-
deletedFiber,
10838-
nearestMountedAncestor,
10839-
destroy
10840-
))
10841-
: (tag & Layout) !== NoFlags &&
10842-
(enableSchedulingProfiler &&
10843-
markComponentLayoutEffectUnmountStarted(deletedFiber),
10844-
shouldProfile(deletedFiber)
10845-
? (startLayoutEffectTimer(),
10846-
(inst.destroy = void 0),
10847-
runWithFiberInDEV(
10848-
deletedFiber,
10849-
callDestroyInDEV,
10850-
deletedFiber,
10851-
nearestMountedAncestor,
10852-
destroy
10853-
),
10854-
recordLayoutEffectDuration(deletedFiber))
10855-
: ((inst.destroy = void 0),
10856-
runWithFiberInDEV(
10857-
deletedFiber,
10858-
callDestroyInDEV,
10859-
deletedFiber,
10860-
nearestMountedAncestor,
10861-
destroy
10862-
)),
10863-
enableSchedulingProfiler &&
10864-
markComponentLayoutEffectUnmountStopped()));
10865-
_prevHostParentIsContainer = _prevHostParentIsContainer.next;
10866-
} while (_prevHostParentIsContainer !== _prevHostParent);
10881+
do
10882+
(tag = _prevHostParentIsContainer.tag),
10883+
(inst = _prevHostParentIsContainer.inst),
10884+
(destroy = inst.destroy),
10885+
void 0 !== destroy &&
10886+
((tag & Insertion) !== NoFlags
10887+
? ((inst.destroy = void 0),
10888+
safelyCallDestroy(
10889+
deletedFiber,
10890+
nearestMountedAncestor,
10891+
destroy
10892+
))
10893+
: (tag & Layout) !== NoFlags &&
10894+
(enableSchedulingProfiler &&
10895+
markComponentLayoutEffectUnmountStarted(deletedFiber),
10896+
shouldProfile(deletedFiber)
10897+
? (startLayoutEffectTimer(),
10898+
(inst.destroy = void 0),
10899+
safelyCallDestroy(
10900+
deletedFiber,
10901+
nearestMountedAncestor,
10902+
destroy
10903+
),
10904+
recordLayoutEffectDuration(deletedFiber))
10905+
: ((inst.destroy = void 0),
10906+
safelyCallDestroy(
10907+
deletedFiber,
10908+
nearestMountedAncestor,
10909+
destroy
10910+
)),
10911+
enableSchedulingProfiler &&
10912+
markComponentLayoutEffectUnmountStopped())),
10913+
(_prevHostParentIsContainer = _prevHostParentIsContainer.next);
10914+
while (_prevHostParentIsContainer !== _prevHostParent);
1086710915
}
1086810916
recursivelyTraverseDeletionEffects(
1086910917
finishedRoot,
@@ -14863,6 +14911,8 @@ __DEV__ &&
1486314911
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
1486414912
enableRetryLaneExpiration = dynamicFeatureFlags.enableRetryLaneExpiration,
1486514913
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
14914+
enableHiddenSubtreeInsertionEffectCleanup =
14915+
dynamicFeatureFlags.enableHiddenSubtreeInsertionEffectCleanup,
1486614916
renameElementSymbol = dynamicFeatureFlags.renameElementSymbol,
1486714917
retryLaneExpirationMs = dynamicFeatureFlags.retryLaneExpirationMs,
1486814918
syncLaneExpirationMs = dynamicFeatureFlags.syncLaneExpirationMs,
@@ -17062,11 +17112,11 @@ __DEV__ &&
1706217112
(function () {
1706317113
var internals = {
1706417114
bundleType: 1,
17065-
version: "19.0.0-www-classic-94e4acaa-20240913",
17115+
version: "19.0.0-www-classic-d3d4d3a4-20240913",
1706617116
rendererPackageName: "react-art",
1706717117
currentDispatcherRef: ReactSharedInternals,
1706817118
findFiberByHostInstance: getInstanceFromNode,
17069-
reconcilerVersion: "19.0.0-www-classic-94e4acaa-20240913"
17119+
reconcilerVersion: "19.0.0-www-classic-d3d4d3a4-20240913"
1707017120
};
1707117121
internals.overrideHookState = overrideHookState;
1707217122
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -17100,7 +17150,7 @@ __DEV__ &&
1710017150
exports.Shape = Shape;
1710117151
exports.Surface = Surface;
1710217152
exports.Text = Text;
17103-
exports.version = "19.0.0-www-classic-94e4acaa-20240913";
17153+
exports.version = "19.0.0-www-classic-d3d4d3a4-20240913";
1710417154
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1710517155
"function" ===
1710617156
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)