Skip to content

Commit 3ec1561

Browse files
committed
Implement renderIntoDocument
This commit adds the function renderIntoDocument in react-dom/server and adds the ability to embed the rendered children in the necessary html tags to repereset a full document. this means you can render "<html>...</html>" or "<div>...</div>" and either way the render will emit html, head, and body tags as necessary to describe a valid and complete HTML page. Like renderIntoContainer, renderIntoDocument provides a stream immediately. While there is a shell of sorts this fucntion will start writing content from the preamble (html and head tags, plus resources that flush in the head) before finishing the shell. Additionally renderIntoContainer accepts fallback children and fallback bootstrap script options. If the Shell errors the fallback children will render instead of children. The expectation is that the client will attempt to render fresh on the client.
1 parent 8e5cd60 commit 3ec1561

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1843
-168
lines changed

packages/react-dom-bindings/src/server/ReactDOMFloatServer.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ export type Resources = {
129129
preconnects: Set<LinkResource>,
130130
fontPreloads: Set<PreloadResource>,
131131
// usedImagePreloads: Set<PreloadResource>,
132+
firstPrecedence: string,
133+
firstPrecedenceFlushed: boolean,
132134
precedences: Map<string, Set<StyleResource>>,
133135
usedStylePreloads: Set<PreloadResource>,
134136
scripts: Set<ScriptResource>,
@@ -161,6 +163,8 @@ export function createResources(): Resources {
161163
preconnects: new Set(),
162164
fontPreloads: new Set(),
163165
// usedImagePreloads: new Set(),
166+
firstPrecedence: '',
167+
firstPrecedenceFlushed: false,
164168
precedences: new Map(),
165169
usedStylePreloads: new Set(),
166170
scripts: new Set(),
@@ -485,14 +489,17 @@ function createStyleResource(
485489
);
486490
}
487491
}
488-
const {stylesMap, preloadsMap, precedences} = resources;
492+
const {stylesMap, preloadsMap, precedences, firstPrecedence} = resources;
489493

490494
// If this is the first time we've seen this precedence we encode it's position in our set even though
491495
// we don't add the resource to this set yet
492496
let precedenceSet = precedences.get(precedence);
493497
if (!precedenceSet) {
494498
precedenceSet = new Set();
495499
precedences.set(precedence, precedenceSet);
500+
if (!firstPrecedence) {
501+
resources.firstPrecedence = precedence;
502+
}
496503
}
497504

498505
let hint = preloadsMap.get(href);

0 commit comments

Comments
 (0)