Skip to content

Commit ff89f2b

Browse files
committed
Move isArray check higher
It's much more likely to be an array than Map or TypedArray.
1 parent 748ab8a commit ff89f2b

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/react-client/src/ReactFlightReplyClient.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ export function processReply(
230230
);
231231
return serializePromiseID(promiseId);
232232
}
233+
if (isArray(value)) {
234+
// $FlowFixMe[incompatible-return]
235+
return value;
236+
}
233237
// TODO: Should we the Object.prototype.toString.call() to test for cross-realm objects?
234238
if (value instanceof FormData) {
235239
if (formData === null) {
@@ -266,10 +270,6 @@ export function processReply(
266270
formData.append(formFieldPrefix + setId, partJSON);
267271
return serializeSetID(setId);
268272
}
269-
if (isArray(value)) {
270-
// $FlowFixMe[incompatible-return]
271-
return value;
272-
}
273273
const iteratorFn = getIteratorFn(value);
274274
if (iteratorFn) {
275275
return Array.from((value: any));

packages/react-server/src/ReactFlightServer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,11 @@ function resolveModelToJSON(
10491049
return (undefined: any);
10501050
}
10511051

1052+
if (isArray(value)) {
1053+
// $FlowFixMe[incompatible-return]
1054+
return value;
1055+
}
1056+
10521057
if (value instanceof Map) {
10531058
return serializeMap(request, value);
10541059
}
@@ -1110,11 +1115,6 @@ function resolveModelToJSON(
11101115
}
11111116
}
11121117

1113-
if (isArray(value)) {
1114-
// $FlowFixMe[incompatible-return]
1115-
return value;
1116-
}
1117-
11181118
const iteratorFn = getIteratorFn(value);
11191119
if (iteratorFn) {
11201120
return Array.from((value: any));

0 commit comments

Comments
 (0)