Skip to content

Commit 8839e50

Browse files
committed
[Fiber] render boundary in fallback if it contains a new stylesheet during sync update
When we implemented Suspensey CSS we had a heuristic that if the update was sync we would ignore the loading states of any new stylesheets and just do the commit. But for a stylesheet capability to be useful it needs to reliably prevent FOUC and since the stylesheet api is opt-in through precedence we don't have to maintain backaward compat (old stylesheets do not block commit but then nobody really renders them because of FOUC anyway) This update modifies the logic to put a boundary back into fallback if a sync update would lead to a stylesheet commiting before it loaded.
1 parent 0a0a5c0 commit 8839e50

File tree

8 files changed

+495
-104
lines changed

8 files changed

+495
-104
lines changed

Diff for: packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3154,7 +3154,6 @@ export function mayResourceSuspendCommit(resource: Resource): boolean {
31543154
}
31553155

31563156
export function preloadInstance(type: Type, props: Props): boolean {
3157-
// Return true to indicate it's already loaded
31583157
return true;
31593158
}
31603159

@@ -3163,10 +3162,11 @@ export function preloadResource(resource: Resource): boolean {
31633162
resource.type === 'stylesheet' &&
31643163
(resource.state.loading & Settled) === NotLoaded
31653164
) {
3166-
// we have not finished loading the underlying stylesheet yet.
3165+
// Return false to indicate this resource should suspend
31673166
return false;
31683167
}
3169-
// Return true to indicate it's already loaded
3168+
3169+
// Return true to indicate this resource should not suspend
31703170
return true;
31713171
}
31723172

0 commit comments

Comments
 (0)