Skip to content
Permalink
Browse files
[Flight] Use lazy reference for existing modules (#20445)
  • Loading branch information
gaearon committed Dec 11, 2020
1 parent 3f9205c commit daf38ecdfcda32a1050231fcc6dea364f8b102e3
Showing with 8 additions and 0 deletions.
  1. +8 −0 packages/react-server/src/ReactFlightServer.js
@@ -435,6 +435,14 @@ export function resolveModelToJSON(
const writtenModules = request.writtenModules;
const existingId = writtenModules.get(moduleKey);
if (existingId !== undefined) {
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
// If we're encoding the "type" of an element, we can refer
// to that by a lazy reference instead of directly since React
// knows how to deal with lazy values. This lets us suspend
// on this component rather than its parent until the code has
// loaded.
return serializeByRefID(existingId);
}
return serializeByValueID(existingId);
}
try {

0 comments on commit daf38ec

Please sign in to comment.