-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
[Fizz] Readability refactor (follow up to #25437) #25865
base: main
Are you sure you want to change the base?
Conversation
Comparing: b14d7fa...d19472b Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
@gnoff ping for feedback 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced each variant needs to be broken out into separate functions but I already felt the pain of the previous factoring when implementing renderIntoContainer
and did a very similar reorganization of the writeCompletedBoundary
implementation.
Because rebasing that PR onto this may be riskier than the other way around do you mind waiting until that one merges in and then rebasing onto it?
if ( | ||
!enableFizzExternalRuntime || | ||
responseState.streamingFormat === ScriptStreamingFormat; | ||
if (scriptFormat) { | ||
writeChunk(destination, responseState.startInlineScript); | ||
if (!responseState.sentCompleteSegmentFunction) { | ||
// The first time we write this, we'll need to include the full implementation. | ||
responseState.sentCompleteSegmentFunction = true; | ||
writeChunk(destination, completeSegmentScript1Full); | ||
} else { | ||
// Future calls can just reuse the same function. | ||
writeChunk(destination, completeSegmentScript1Partial); | ||
} | ||
responseState.streamingFormat === ScriptStreamingFormat | ||
) { | ||
return writeCompletedSegmentInstructionScript( | ||
destination, | ||
responseState, | ||
contentSegmentID, | ||
); | ||
} else { | ||
return writeCompletedSegmentInstructionData( | ||
destination, | ||
responseState, | ||
contentSegmentID, | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello @mofeiZ
how about this?
I think else seems unnecessary 😄
if (
!enableFizzExternalRuntime ||
responseState.streamingFormat === ScriptStreamingFormat
) {
return writeCompletedSegmentInstructionScript(
destination,
responseState,
contentSegmentID,
);
}
return writeCompletedSegmentInstructionData(
destination,
responseState,
contentSegmentID,
);
Summary
Follow-up / cleanup PR to #25437
write[...]Instruction
into two sets of functions, functions writing the inline script format and functions writing the data attribute format. This is only moving code around (no functional changes)How did you test this change?
ReactDOMFizzServer-test.js
ReactDOMFloat-test.js