Skip to content

Commit e26781e

Browse files
committed
Failing test for deduped props of elements in fragments
1 parent bea5a2b commit e26781e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMBrowser-test.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,53 @@ describe('ReactFlightDOMBrowser', () => {
525525
expect(container.innerHTML).toBe('{"foo":1}{"foo":1}');
526526
});
527527

528+
it('should handle deduped props of elements in fragments', async () => {
529+
let resolveFooClientComponentChunk;
530+
531+
const FooClient = clientExports(
532+
function Foo({children, item}) {
533+
return children;
534+
},
535+
'1',
536+
'/foo.js',
537+
new Promise(resolve => (resolveFooClientComponentChunk = resolve)),
538+
);
539+
540+
const shared = <div />;
541+
542+
function Server() {
543+
return (
544+
<FooClient track={shared}>
545+
<React.Fragment>{shared}</React.Fragment>
546+
</FooClient>
547+
);
548+
}
549+
550+
const stream = await serverAct(() =>
551+
ReactServerDOMServer.renderToReadableStream(<Server />, webpackMap),
552+
);
553+
554+
function ClientRoot({response}) {
555+
return use(response);
556+
}
557+
558+
const response = ReactServerDOMClient.createFromReadableStream(stream);
559+
const container = document.createElement('div');
560+
const root = ReactDOMClient.createRoot(container);
561+
562+
await act(() => {
563+
root.render(<ClientRoot response={response} />);
564+
});
565+
566+
expect(container.innerHTML).toBe('');
567+
568+
await act(() => {
569+
resolveFooClientComponentChunk();
570+
});
571+
572+
expect(container.innerHTML).toBe('<div></div>');
573+
});
574+
528575
it('should progressively reveal server components', async () => {
529576
let reportedErrors = [];
530577

0 commit comments

Comments
 (0)