Skip to content

Commit

Permalink
Call cleanup of insertion effects when hidden (#30954)
Browse files Browse the repository at this point in the history
Summary:
bypass
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 facebook/react#26670

---------

DiffTrain build for commit facebook/react@d3d4d3a.

Reviewed By: kassens

Differential Revision: D62661120

Pulled By: josephsavona

fbshipit-source-id: 81412821e4f100fb5acb4b54e8946fe03b389115

Co-authored-by: Rick Hanlon <rickhanlonii@fb.com>
  • Loading branch information
2 people authored and facebook-github-bot committed Sep 17, 2024
1 parent c79f1e6 commit 186c917
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions packages/react-relay/relay-hooks/__tests__/useQueryLoader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,11 +755,7 @@ describe.each([
expect(outerInstance?.toJSON()).toEqual('fallback');
expect(releaseQuery).not.toHaveBeenCalled();
ReactTestRenderer.act(() => outerInstance?.unmount());
if (ENABLE_ACTIVITY_COMPATIBILITY) {
expect(releaseQuery).toHaveBeenCalledTimes(0);
jest.runAllTimers();
expect(releaseQuery).toHaveBeenCalledTimes(1);
} else {
if (!ENABLE_ACTIVITY_COMPATIBILITY) {
expect(releaseQuery).toHaveBeenCalledTimes(1);
}
});
Expand Down Expand Up @@ -812,11 +808,7 @@ describe.each([
expect(outerInstance?.toJSON()).toEqual('fallback');
expect(releaseQuery).not.toHaveBeenCalled();
ReactTestRenderer.act(() => outerInstance?.unmount());
if (ENABLE_ACTIVITY_COMPATIBILITY) {
expect(releaseQuery).toHaveBeenCalledTimes(0);
jest.runAllTimers();
expect(releaseQuery).toHaveBeenCalledTimes(1);
} else {
if (!ENABLE_ACTIVITY_COMPATIBILITY) {
expect(releaseQuery).toHaveBeenCalledTimes(1);
}
});
Expand Down

0 comments on commit 186c917

Please sign in to comment.