Skip to content

Commit

Permalink
Swap the primary renderer flag in the legacy stream config
Browse files Browse the repository at this point in the history
This allows the legacy implementation to co-exist with the new
implementation.

But primarily it allows Fiber and the legacy renderToString to co-exist.
  • Loading branch information
sebmarkbage committed Apr 27, 2021
1 parent ed027a6 commit fd89f83
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export type Destination = {
export type PrecomputedChunk = string;
export type Chunk = string;

export const isPrimaryStreamConfig = false;

export function scheduleWork(callback: () => void) {
callback();
}
Expand Down
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

0 comments on commit fd89f83

Please sign in to comment.