mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
handled a missing suspense fiber when suspense is filtered on the profiler (#19987)
Co-authored-by: Brian Vaughn <bvaughn@fb.com>
This commit is contained in:
@@ -84,6 +84,19 @@ exports[`Store component filters should ignore invalid ElementTypeRoot filter: 2
|
||||
<div>
|
||||
`;
|
||||
|
||||
exports[`Store component filters should not break when Suspense nodes are filtered from the tree: 1: suspended 1`] = `
|
||||
[root]
|
||||
▾ <Wrapper>
|
||||
▾ <Loading>
|
||||
<div>
|
||||
`;
|
||||
|
||||
exports[`Store component filters should not break when Suspense nodes are filtered from the tree: 2: resolved 1`] = `
|
||||
[root]
|
||||
▾ <Wrapper>
|
||||
<Component>
|
||||
`;
|
||||
|
||||
exports[`Store component filters should support filtering by element type: 1: mount 1`] = `
|
||||
[root]
|
||||
▾ <Root>
|
||||
|
||||
@@ -227,4 +227,34 @@ describe('Store component filters', () => {
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it('should not break when Suspense nodes are filtered from the tree', () => {
|
||||
const promise = new Promise(() => {});
|
||||
|
||||
const Loading = () => <div>Loading...</div>;
|
||||
|
||||
const Component = ({shouldSuspend}) => {
|
||||
if (shouldSuspend) {
|
||||
throw promise;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const Wrapper = ({shouldSuspend}) => (
|
||||
<React.Suspense fallback={<Loading />}>
|
||||
<Component shouldSuspend={shouldSuspend} />
|
||||
</React.Suspense>
|
||||
);
|
||||
|
||||
store.componentFilters = [
|
||||
utils.createElementTypeFilter(Types.ElementTypeSuspense),
|
||||
];
|
||||
|
||||
const container = document.createElement('div');
|
||||
act(() => ReactDOM.render(<Wrapper shouldSuspend={true} />, container));
|
||||
expect(store).toMatchSnapshot('1: suspended');
|
||||
|
||||
act(() => ReactDOM.render(<Wrapper shouldSuspend={false} />, container));
|
||||
expect(store).toMatchSnapshot('2: resolved');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1572,7 +1572,7 @@ export function attach(
|
||||
if (nextPrimaryChildSet !== null) {
|
||||
mountFiberRecursively(
|
||||
nextPrimaryChildSet,
|
||||
nextFiber,
|
||||
shouldIncludeInTree ? nextFiber : parentFiber,
|
||||
true,
|
||||
traceNearestHostComponentUpdate,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user