@samitouri / QOS-React / commits / c0cf7c696c

Promote ASYNC_ITERATOR symbol to React Symbols (#28851)

So that when we end up referring to it in more places, it's only one. We don't do this same pattern for regular `Symbol.iterator` because we also support the string `"@@iterator"` for backwards compatibility.

Sebastian Markbåge committed Apr 17, 2024 at 12:29 UTC c0cf7c696cf454b49b35d8dae01ab111739dab46
3 files changed +4 -4
packages/react-client/src/ReactFlightClient.js
+1 -2
@@ -65,6 +65,7 @@ import {
65 REACT_LAZY_TYPE,
66 REACT_ELEMENT_TYPE,
67 REACT_POSTPONE_TYPE,
68 + ASYNC_ITERATOR,
69 } from 'shared/ReactSymbols';
70
71 export type {CallServerCallback, EncodeFormActionCallback};
@@ -1245,8 +1246,6 @@ function startReadableStream<T>(
1246 resolveStream(response, id, stream, flightController);
1247 }
1248
1248 -const ASYNC_ITERATOR = Symbol.asyncIterator;
1249 -
1249 function asyncIterator(this: $AsyncIterator<any, any, void>) {
1250 // Self referencing iterator.
1251 return this;
packages/react-server/src/ReactFlightServer.js
+1 -2
@@ -99,6 +99,7 @@ import {
99 REACT_LAZY_TYPE,
100 REACT_MEMO_TYPE,
101 REACT_POSTPONE_TYPE,
102 + ASYNC_ITERATOR,
103 } from 'shared/ReactSymbols';
104
105 import {
@@ -201,8 +202,6 @@ if (
202
203 const ObjectPrototype = Object.prototype;
204
204 -const ASYNC_ITERATOR = Symbol.asyncIterator;
205 -
205 type JSONValue =
206 | string
207 | boolean
packages/shared/ReactSymbols.js
+2
@@ -60,3 +60,5 @@ export function getIteratorFn(maybeIterable: ?any): ?() => ?Iterator<any> {
60 }
61 return null;
62 }
63 +
64 +export const ASYNC_ITERATOR = Symbol.asyncIterator;