mirror of
https://github.com/facebook/react.git
synced 2026-02-21 19:31:52 +00:00
[DevTools] Fix crash when revealing stable, filtered <Activity> children (#35734)
This commit is contained in:
committed by
GitHub
parent
24f215ce8b
commit
4c9d62d2b4
@@ -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>
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user