Skip to content

Commit 307c090

Browse files
committed
Implement fallback children
When you pass a fallback to renderIntoDocument it will emit the fallback if the shell of the primary children errors. It is possible for the fallback to also error in the shell in which case the result is a fatalError as if you did not provide a fallback. Included in this change is a refactoring of how preamble and postamble work. They are now interned within the resposneState where we can have more careful control over what is flushed and when. There is also a new concept of an early preamble. the early preamble is the html and head tags plus any resources that can flush (most things plus stylesheets up to the first precedence)
1 parent fc2b823 commit 307c090

9 files changed

Lines changed: 863 additions & 245 deletions

File tree

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)