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
Switch the isPrimaryRender flag based on the stream config
It's possible for Fizz and Fiber to co-exist for example. If they both
end up using the same context field then that can clash.

It's also possible for e.g. DOM and ART to co-exist on the server.

Or Legacy Fizz DOM and Modern Fizz DOM.

Instead of protecting against every possible clash, I just took the most
common one. E.g. renderToString clashing with either Fiber or Modern Fizz.

I flip it in the legacy stream config.
  • Loading branch information
sebmarkbage committed Apr 27, 2021
commit dfe709441900b6062d91d938134740e2d308ecb0
3 changes: 2 additions & 1 deletion packages/react-dom/src/server/ReactDOMServerFormatConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
writeChunk,
stringToChunk,
stringToPrecomputedChunk,
isPrimaryStreamConfig,
} from 'react-server/src/ReactServerStreamConfig';

import {
Expand Down Expand Up @@ -50,7 +51,7 @@ import isArray from 'shared/isArray';

// Used to distinguish these contexts from ones used in other renderers.
// E.g. this can be used to distinguish legacy renderers from this modern one.
export const isPrimaryRenderer = true;
export const isPrimaryRenderer = isPrimaryStreamConfig;

// Per response, global state that is not contextual to the rendering subtree.
export type ResponseState = {
Expand Down
2 changes: 2 additions & 0 deletions packages/react-server/src/ReactServerStreamConfigBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export type Destination = ReadableStreamController;
export type PrecomputedChunk = Uint8Array;
export type Chunk = Uint8Array;

export const isPrimaryStreamConfig = true;

export function scheduleWork(callback: () => void) {
callback();
}
Expand Down
2 changes: 2 additions & 0 deletions packages/react-server/src/ReactServerStreamConfigNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export type Destination = Writable & MightBeFlushable;
export type PrecomputedChunk = Uint8Array;
export type Chunk = string;

export const isPrimaryStreamConfig = true;

export function scheduleWork(callback: () => void) {
setImmediate(callback);
}
Expand Down