Skip to content

Commit c0cf7c6

Browse files
authored
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.
1 parent 657428a commit c0cf7c6

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

packages/react-client/src/ReactFlightClient.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import {
6565
REACT_LAZY_TYPE,
6666
REACT_ELEMENT_TYPE,
6767
REACT_POSTPONE_TYPE,
68+
ASYNC_ITERATOR,
6869
} from 'shared/ReactSymbols';
6970

7071
export type {CallServerCallback, EncodeFormActionCallback};
@@ -1245,8 +1246,6 @@ function startReadableStream<T>(
12451246
resolveStream(response, id, stream, flightController);
12461247
}
12471248

1248-
const ASYNC_ITERATOR = Symbol.asyncIterator;
1249-
12501249
function asyncIterator(this: $AsyncIterator<any, any, void>) {
12511250
// Self referencing iterator.
12521251
return this;

packages/react-server/src/ReactFlightServer.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import {
9999
REACT_LAZY_TYPE,
100100
REACT_MEMO_TYPE,
101101
REACT_POSTPONE_TYPE,
102+
ASYNC_ITERATOR,
102103
} from 'shared/ReactSymbols';
103104

104105
import {
@@ -201,8 +202,6 @@ if (
201202

202203
const ObjectPrototype = Object.prototype;
203204

204-
const ASYNC_ITERATOR = Symbol.asyncIterator;
205-
206205
type JSONValue =
207206
| string
208207
| boolean

packages/shared/ReactSymbols.js

+2
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,5 @@ export function getIteratorFn(maybeIterable: ?any): ?() => ?Iterator<any> {
6060
}
6161
return null;
6262
}
63+
64+
export const ASYNC_ITERATOR = Symbol.asyncIterator;

0 commit comments

Comments
 (0)