Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ function initializeDebugChunk(
waitForReference(
debugChunk,
{}, // noop, since we'll have already added an entry to debug info
'', // noop
'debug', // noop, but we need it to not be empty string since that indicates the root object
response,
initializeDebugInfo,
[''], // path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1915,4 +1915,57 @@ describe('ReactFlightDOMEdge', () => {
expect(ownerStack).toBeNull();
}
});

it('can pass an async import that resolves later as a prop to a null component', async () => {
let resolveClientComponentChunk;
const client = clientExports(
{
foo: 'bar',
},
'42',
'/test.js',
new Promise(resolve => (resolveClientComponentChunk = resolve)),
);

function ServerComponent(props) {
return null;
}

function App() {
return (
<div>
<ServerComponent client={client} />
</div>
);
}

const stream = await serverAct(() =>
passThrough(
ReactServerDOMServer.renderToReadableStream(<App />, webpackMap),
),
);

// Parsing the root blocks because the module hasn't loaded yet
const response = ReactServerDOMClient.createFromReadableStream(stream, {
serverConsumerManifest: {
moduleMap: null,
moduleLoading: null,
},
});

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

// Initialize to be blocked.
response.then(() => {});
// Unblock.
resolveClientComponentChunk();

const ssrStream = await serverAct(() =>
ReactDOMServer.renderToReadableStream(<ClientRoot />),
);
const result = await readResult(ssrStream);
expect(result).toEqual('<div></div>');
});
});
Loading