[DevTools] Fix crash when revealing stable, filtered <Activity> children (#35734)

This commit is contained in:
Sebastian "Sebbie" Silbermann
2026-02-09 22:52:24 +01:00
committed by GitHub
parent 24f215ce8b
commit 4c9d62d2b4
2 changed files with 55 additions and 0 deletions

View File

@@ -3572,4 +3572,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>
`);
});
});

View File

@@ -5416,6 +5416,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 &&