Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[Flight] Use lazy reference for existing modules (
#20445)
- Loading branch information
Showing
with
8 additions
and
0 deletions.
-
+8
−0
packages/react-server/src/ReactFlightServer.js
There are no files selected for viewing
|
|
@@ -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 { |
|
|
|
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.