Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flight] Add failing test to reproduce issue with Object.freeze #29129

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,55 @@ describe('ReactFlightDOMBrowser', () => {
});
});

it('should resolve client components (with async chunks) when referenced in props', async () => {
let resolveClientComponentChunk;

const ClientOuter = clientExports(function ClientOuter({
Component,
children,
}) {
return <Component>{children}</Component>;
});

const ClientInner = clientExports(
function ClientInner({children}) {
return <span>{children}</span>;
},
'42',
'/test.js',
new Promise(resolve => (resolveClientComponentChunk = resolve)),
);

function Server() {
return <ClientOuter Component={ClientInner}>Hello, World!</ClientOuter>;
}

const stream = ReactServerDOMServer.renderToReadableStream(
<Server />,
webpackMap,
);

function ClientRoot({response}) {
return use(response);
}

const response = ReactServerDOMClient.createFromReadableStream(stream);
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);

await act(() => {
root.render(<ClientRoot response={response} />);
});

expect(container.innerHTML).toBe('');

await act(() => {
resolveClientComponentChunk();
});

expect(container.innerHTML).toBe('<span>Hello, World!</span>');
});

it('should progressively reveal server components', async () => {
let reportedErrors = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ exports.clientExports = function clientExports(
moduleExports,
chunkId,
chunkFilename,
blockOnChunk,
) {
const chunks = [];
if (chunkId) {
chunks.push(chunkId, chunkFilename);

if (blockOnChunk) {
webpackChunkMap[chunkId] = blockOnChunk;
}
}
const idx = '' + webpackModuleIdx++;
webpackClientModules[idx] = moduleExports;
Expand Down