Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename from iterator to iterable and split the functionality #19831

Merged
merged 9 commits into from
Sep 22, 2020
6 changes: 6 additions & 0 deletions packages/react-devtools-shared/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
import {localStorageGetItem, localStorageSetItem} from './storage';
import {meta} from './hydration';
import type {ComponentFilter, ElementType} from './types';
import {symbol} from 'prop-types';
todortotev marked this conversation as resolved.
Show resolved Hide resolved

const cachedDisplayNames: WeakMap<Function, string> = new WeakMap();

Expand Down Expand Up @@ -615,6 +616,11 @@ export function formatDataForPreview(
}
case 'iterator':
const name = data.constructor.name;
// We check if the the generator returns itself.
// If it does, we want to avoid iterating over it.
if (typeof data[Symbol.iterator]() === 'object') {
return `${name}(${data.size})`;
}
if (showFormattedValue) {
// TRICKY
// Don't use [...spread] syntax for this purpose.
Expand Down