Skip to content

Commit

Permalink
Call cleanup of insertion effects when hidden (#30954)
Browse files Browse the repository at this point in the history
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 <rickhanlonii@fb.com>

DiffTrain build for commit d3d4d3a.
  • Loading branch information
rickhanlonii committed Sep 13, 2024
1 parent 03205d9 commit b42180d
Show file tree
Hide file tree
Showing 14 changed files with 575 additions and 335 deletions.
2 changes: 1 addition & 1 deletion compiled-rn/VERSION_NATIVE_FB
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19.0.0-native-fb-94e4acaa-20240913
19.0.0-native-fb-d3d4d3a4-20240913
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<7a44af74badbc39b3911200f0c8f1ea4>>
* @generated SignedSource<<2d89a3e686f85aa5ee5696aad303b4b0>>
*/

"use strict";
__DEV__ &&
(function () {
function JSCompiler_object_inline_createNodeMock_1105() {
function JSCompiler_object_inline_createNodeMock_1109() {
return null;
}
function findHook(fiber, id) {
Expand Down Expand Up @@ -9384,12 +9384,11 @@ __DEV__ &&
case 11:
case 14:
case 15:
_prevHostParent = deletedFiber.updateQueue;
if (
!offscreenSubtreeWasHidden &&
((_prevHostParent = deletedFiber.updateQueue),
null !== _prevHostParent &&
((_prevHostParent = _prevHostParent.lastEffect),
null !== _prevHostParent))
((_prevHostParent = _prevHostParent.lastEffect),
null !== _prevHostParent)
) {
_prevHostParentIsContainer = _prevHostParent = _prevHostParent.next;
do {
Expand All @@ -9398,15 +9397,18 @@ __DEV__ &&
destroy = inst.destroy;
void 0 !== destroy &&
((tag & Insertion) !== NoFlags
? ((inst.destroy = void 0),
? ((isRunningInsertionEffect = !0),
(inst.destroy = void 0),
runWithFiberInDEV(
deletedFiber,
callDestroyInDEV,
deletedFiber,
nearestMountedAncestor,
destroy
))
: (tag & Layout) !== NoFlags &&
),
(isRunningInsertionEffect = !1))
: offscreenSubtreeWasHidden ||
(tag & Layout) === NoFlags ||
(markComponentLayoutEffectUnmountStarted(deletedFiber),
shouldProfile(deletedFiber)
? (startLayoutEffectTimer(),
Expand Down Expand Up @@ -15122,11 +15124,11 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.0.0-native-fb-94e4acaa-20240913",
version: "19.0.0-native-fb-d3d4d3a4-20240913",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: getInstanceFromNode,
reconcilerVersion: "19.0.0-native-fb-94e4acaa-20240913"
reconcilerVersion: "19.0.0-native-fb-d3d4d3a4-20240913"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
Expand All @@ -15148,7 +15150,7 @@ __DEV__ &&
exports._Scheduler = Scheduler;
exports.act = act;
exports.create = function (element, options) {
var createNodeMock = JSCompiler_object_inline_createNodeMock_1105,
var createNodeMock = JSCompiler_object_inline_createNodeMock_1109,
isConcurrent = !1,
isStrictMode = !1;
"object" === typeof options &&
Expand Down Expand Up @@ -15271,5 +15273,5 @@ __DEV__ &&
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.0.0-native-fb-94e4acaa-20240913";
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
})();
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<79c30664ec056acbff09d56e15b605d0>>
* @generated SignedSource<<4f55ec78358c8ebecf4eaa369cc81849>>
*/

"use strict";
Expand Down Expand Up @@ -6635,11 +6635,8 @@ function commitDeletionEffectsOnFiber(
case 11:
case 14:
case 15:
if (
!offscreenSubtreeWasHidden &&
((index = deletedFiber.updateQueue),
null !== index && ((index = index.lastEffect), null !== index))
) {
index = deletedFiber.updateQueue;
if (null !== index && ((index = index.lastEffect), null !== index)) {
index$jscomp$0 = index = index.next;
do {
prevHostParent = index$jscomp$0.tag;
Expand All @@ -6653,7 +6650,8 @@ function commitDeletionEffectsOnFiber(
nearestMountedAncestor,
destroy
))
: 0 !== (prevHostParent & 4) &&
: offscreenSubtreeWasHidden ||
0 === (prevHostParent & 4) ||
((prevHostParentIsContainer.destroy = void 0),
safelyCallDestroy(
deletedFiber,
Expand Down Expand Up @@ -9488,14 +9486,14 @@ function wrapFiber(fiber) {
}
var internals$jscomp$inline_1266 = {
bundleType: 0,
version: "19.0.0-native-fb-94e4acaa-20240913",
version: "19.0.0-native-fb-d3d4d3a4-20240913",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: function (mockNode) {
mockNode = nodeToInstanceMap.get(mockNode);
return void 0 !== mockNode ? mockNode.internalInstanceHandle : null;
},
reconcilerVersion: "19.0.0-native-fb-94e4acaa-20240913"
reconcilerVersion: "19.0.0-native-fb-d3d4d3a4-20240913"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1267 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down Expand Up @@ -9631,4 +9629,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.0.0-native-fb-94e4acaa-20240913";
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<1b967cee52d371092874f9ae20a82460>>
* @generated SignedSource<<b264040d9a17e92d86c094ff1ead550e>>
*/

"use strict";
Expand Down Expand Up @@ -7049,11 +7049,8 @@ function commitDeletionEffectsOnFiber(
case 11:
case 14:
case 15:
if (
!offscreenSubtreeWasHidden &&
((index = deletedFiber.updateQueue),
null !== index && ((index = index.lastEffect), null !== index))
) {
index = deletedFiber.updateQueue;
if (null !== index && ((index = index.lastEffect), null !== index)) {
index$jscomp$0 = index = index.next;
do {
prevHostParent = index$jscomp$0.tag;
Expand All @@ -7067,7 +7064,8 @@ function commitDeletionEffectsOnFiber(
nearestMountedAncestor,
destroy
))
: 0 !== (prevHostParent & 4) &&
: offscreenSubtreeWasHidden ||
0 === (prevHostParent & 4) ||
(markComponentLayoutEffectUnmountStarted(deletedFiber),
shouldProfile(deletedFiber)
? (startLayoutEffectTimer(),
Expand Down Expand Up @@ -10076,14 +10074,14 @@ function wrapFiber(fiber) {
}
var internals$jscomp$inline_1141 = {
bundleType: 0,
version: "19.0.0-native-fb-94e4acaa-20240913",
version: "19.0.0-native-fb-d3d4d3a4-20240913",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
findFiberByHostInstance: function (mockNode) {
mockNode = nodeToInstanceMap.get(mockNode);
return void 0 !== mockNode ? mockNode.internalInstanceHandle : null;
},
reconcilerVersion: "19.0.0-native-fb-94e4acaa-20240913",
reconcilerVersion: "19.0.0-native-fb-d3d4d3a4-20240913",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$138 = 0;
Expand Down Expand Up @@ -10234,4 +10232,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.0.0-native-fb-94e4acaa-20240913";
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<311f6e22a22d12061756c8044a0696a3>>
* @generated SignedSource<<598e1a1554be705744125c5f6e86546f>>
*/

"use strict";
Expand Down Expand Up @@ -1705,7 +1705,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.0.0-native-fb-94e4acaa-20240913";
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<22d627e46625db555a755a27eabe5462>>
* @generated SignedSource<<b8568e853b095ed822fa12f152e3121e>>
*/

"use strict";
Expand Down Expand Up @@ -580,4 +580,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-native-fb-94e4acaa-20240913";
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<587bcb4d44e630fb36fd55546d100d27>>
* @generated SignedSource<<92d8fbd56fb11e8c6a3aad4c04d6df3c>>
*/

"use strict";
Expand Down Expand Up @@ -584,7 +584,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-native-fb-94e4acaa-20240913";
exports.version = "19.0.0-native-fb-d3d4d3a4-20240913";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
94e4acaa1477e65cac02ba86058cde0afe4c8f1f
d3d4d3a46b014ab0f6edc443c19fcdba09105f20
Loading

0 comments on commit b42180d

Please sign in to comment.