Skip to content

Commit

Permalink
Test to assert that hydration errors of an inner suspended boundary a…
Browse files Browse the repository at this point in the history
…re not retained by an unsuspended outer boundary
  • Loading branch information
gnoff committed May 25, 2022
1 parent b2763d3 commit b1fbb14
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3531,4 +3531,50 @@ describe('ReactDOMFizzServer', () => {
console.error = originalConsoleError;
}
});

// @gate experimental
it('#24578 Hydration errors caused by a suspending component should not become recoverable when nested in an ancestor Suspense that is showing primary content', async () => {
// this test failed before because hydration errors on the inner boundary were upgraded to recoverable by
// a codepath of the outer boundary
function App({isClient}) {
return (
<Suspense fallback={'outer'}>
<Suspense fallback={'inner'}>
<div>
{isClient ? <AsyncText text="A" /> : <Text text="A" />}
<b>B</b>
</div>
</Suspense>
</Suspense>
);
}
await act(async () => {
const {pipe} = ReactDOMFizzServer.renderToPipeableStream(<App />);
pipe(writable);
});

let errors = [];
ReactDOMClient.hydrateRoot(container, <App isClient />, {
onRecoverableError(error) {
errors.push(error.message);
},
});

expect(Scheduler).toFlushAndYield([]);
expect(errors).toEqual([]);
expect(getVisibleChildren(container)).toEqual(
<div>
A<b>B</b>
</div>,
);

resolveText('A');
expect(Scheduler).toFlushAndYield([]);
expect(errors).toEqual([]);
expect(getVisibleChildren(container)).toEqual(
<div>
A<b>B</b>
</div>,
);
});
});

0 comments on commit b1fbb14

Please sign in to comment.