Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions packages/react-devtools-shared/src/__tests__/store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3538,4 +3538,48 @@ describe('Store', () => {
<Suspense name="inner" rects={[{x:1,y:2,width:14,height:1}]}>
`);
});

// @reactVersion >= 19
it('can reconcile newly visible Activity with filtered, stable children', async () => {
const Activity = React.Activity || React.unstable_Activity;

function IgnoreMe({children}) {
return children;
}

function Component({children}) {
return <div>{children}</div>;
}

await actAsync(
async () =>
(store.componentFilters = [createDisplayNameFilter('^IgnoreMe', true)]),
);

const children = (
<IgnoreMe>
<Component key="left">Left</Component>
</IgnoreMe>
);

await actAsync(() => {
render(<Activity mode="hidden">{children}</Activity>);
});

expect(store).toMatchInlineSnapshot(`
[root]
<Activity>
`);

await actAsync(() => {
render(<Activity mode="visible">{children}</Activity>);
});

expect(store).toMatchInlineSnapshot(`
[root]
▾ <Activity>
▾ <Component key="left">
<div>
`);
});
});
11 changes: 11 additions & 0 deletions packages/react-devtools-shared/src/backend/fiber/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5405,6 +5405,17 @@ export function attach(
// We're hiding the children. Remove them from the Frontend
unmountRemainingChildren();
}
} else if (prevWasHidden && !nextIsHidden) {
// Since we don't mount hidden children and unmount children when hiding,
// we need to enter the mount path when revealing.
const nextChildSet = nextFiber.child;
if (nextChildSet !== null) {
mountChildrenRecursively(
nextChildSet,
traceNearestHostComponentUpdate,
);
updateFlags |= ShouldResetChildren | ShouldResetSuspenseChildren;
}
} else if (
nextFiber.tag === SuspenseComponent &&
OffscreenComponent !== -1 &&
Expand Down
Loading