mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[Flight] Don't increase serializedSize for every recursive pass (#33123)
I noticed that we increase this in the recursive part of the algorithm. This would mean that we'd count a key more than once if it has Server Components inside it recursively resolving. This moves it out to where we enter from toJSON. Which is called once per JSON entry (and therefore once per key).
This commit is contained in:
+3
-2
@@ -2302,6 +2302,9 @@ function renderModel(
|
||||
key: string,
|
||||
value: ReactClientValue,
|
||||
): ReactJSONValue {
|
||||
// First time we're serializing the key, we should add it to the size.
|
||||
serializedSize += key.length;
|
||||
|
||||
const prevKeyPath = task.keyPath;
|
||||
const prevImplicitSlot = task.implicitSlot;
|
||||
try {
|
||||
@@ -2416,8 +2419,6 @@ function renderModelDestructive(
|
||||
// Set the currently rendering model
|
||||
task.model = value;
|
||||
|
||||
serializedSize += parentPropertyName.length;
|
||||
|
||||
// Special Symbol, that's very common.
|
||||
if (value === REACT_ELEMENT_TYPE) {
|
||||
return '$';
|
||||
|
||||
Reference in New Issue
Block a user