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

[Fizz/Flight] Don't use default args #21681

Merged
merged 2 commits into from
Jun 14, 2021
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
16 changes: 12 additions & 4 deletions packages/react-dom/src/server/ReactDOMFizzServerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ type Controls = {|
startWriting(): void,
|};

function pipeToNodeWritable(
function createRequestImpl(
children: ReactNodeList,
destination: Writable,
options?: Options,
): Controls {
const request = createRequest(
options: void | Options,
) {
return createRequest(
children,
destination,
createResponseState(options ? options.identifierPrefix : undefined),
Expand All @@ -57,6 +57,14 @@ function pipeToNodeWritable(
options ? options.onCompleteAll : undefined,
options ? options.onReadyToStream : undefined,
);
}

function pipeToNodeWritable(
children: ReactNodeList,
destination: Writable,
options?: Options,
): Controls {
const request = createRequestImpl(children, destination, options);
let hasStartedFlowing = false;
startWork(request);
return {
Expand Down
19 changes: 11 additions & 8 deletions packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,20 @@ export function createRequest(
destination: Destination,
responseState: ResponseState,
rootFormatContext: FormatContext,
progressiveChunkSize: number = DEFAULT_PROGRESSIVE_CHUNK_SIZE,
onError: (error: mixed) => void = defaultErrorHandler,
onCompleteAll: () => void = noop,
onReadyToStream: () => void = noop,
progressiveChunkSize: void | number,
onError: void | ((error: mixed) => void),
onCompleteAll: void | (() => void),
onReadyToStream: void | (() => void),
): Request {
const pingedTasks = [];
const abortSet: Set<Task> = new Set();
const request = {
destination,
responseState,
progressiveChunkSize,
progressiveChunkSize:
progressiveChunkSize === undefined
? DEFAULT_PROGRESSIVE_CHUNK_SIZE
: progressiveChunkSize,
status: BUFFERING,
nextSegmentId: 0,
allPendingTasks: 0,
Expand All @@ -243,9 +246,9 @@ export function createRequest(
clientRenderedBoundaries: [],
completedBoundaries: [],
partialBoundaries: [],
onError,
onCompleteAll,
onReadyToStream,
onError: onError === undefined ? defaultErrorHandler : onError,
onCompleteAll: onCompleteAll === undefined ? noop : onCompleteAll,
onReadyToStream: onReadyToStream === undefined ? noop : onReadyToStream,
};
// This segment represents the root fallback.
const rootSegment = createPendingSegment(request, 0, null, rootFormatContext);
Expand Down
4 changes: 2 additions & 2 deletions packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function createRequest(
model: ReactModel,
destination: Destination,
bundlerConfig: BundlerConfig,
onError: (error: mixed) => void = defaultErrorHandler,
onError: void | ((error: mixed) => void),
): Request {
const pingedSegments = [];
const request = {
Expand All @@ -113,7 +113,7 @@ export function createRequest(
completedErrorChunks: [],
writtenSymbols: new Map(),
writtenModules: new Map(),
onError,
onError: onError === undefined ? defaultErrorHandler : onError,
flowing: false,
toJSON: function(key: string, value: ReactModel): ReactJSONValue {
return resolveModelToJSON(request, this, key, value);
Expand Down