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] Refactor the Render Loop to Behave More Like Fizz #28065

Merged
merged 7 commits into from
Jan 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,20 @@ describe('ReactFlightDOMEdge', () => {
expect(result).toEqual(resolvedChildren);
});

it('should execute repeated server components in a compact form', async () => {
async function ServerComponent({recurse}) {
if (recurse > 0) {
return <ServerComponent recurse={recurse - 1} />;
}
return <div>Fin</div>;
}
const stream = ReactServerDOMServer.renderToReadableStream(
<ServerComponent recurse={20} />,
);
const serializedContent = await readResult(stream);
expect(serializedContent.length).toBeLessThan(150);
});

// @gate enableBinaryFlight
it('should be able to serialize any kind of typed array', async () => {
const buffer = new Uint8Array([
Expand Down
6 changes: 5 additions & 1 deletion packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2201,8 +2201,12 @@ function renderNodeDestructive(
task.node = node;
task.childIndex = childIndex;

if (node === null) {
return;
}

// Handle object types
if (typeof node === 'object' && node !== null) {
if (typeof node === 'object') {
switch ((node: any).$$typeof) {
case REACT_ELEMENT_TYPE: {
const element: any = node;
Expand Down
Loading