From ec0709a74e4132101cb2063296efedd049dfeddf Mon Sep 17 00:00:00 2001 From: eps1lon Date: Fri, 29 Apr 2022 18:59:49 +0200 Subject: [PATCH] generators are one-shot iterators --- .../src/ReactChildFiber.new.js | 32 +++++++++---------- .../src/ReactChildFiber.old.js | 32 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/react-reconciler/src/ReactChildFiber.new.js b/packages/react-reconciler/src/ReactChildFiber.new.js index 992544cba8e62..831fa2a3e30be 100644 --- a/packages/react-reconciler/src/ReactChildFiber.new.js +++ b/packages/react-reconciler/src/ReactChildFiber.new.js @@ -937,6 +937,22 @@ function ChildReconciler(shouldTrackSideEffects) { ); } didWarnAboutGenerators = true; + } else { + // Warn about using one-shot iterators as children + const isOneShotIterator = + iteratorFn.call(newChildrenIterable) === newChildrenIterable; + if (isOneShotIterator) { + if (!didWarnAboutOneShotIterators) { + console.error( + 'Using a TOOD-understandable-term as children is unsupported and will likely yield ' + + 'unexpected results because enumerating a TOOD-understandable-term mutates it. ' + + 'You may convert it to an array with `Array.from()` or the ' + + '`[...spread]` operator before rendering. Keep in mind ' + + 'you might need to polyfill these features for older browsers.', + ); + } + didWarnAboutOneShotIterators = true; + } } // Warn about using Maps as children @@ -950,22 +966,6 @@ function ChildReconciler(shouldTrackSideEffects) { didWarnAboutMaps = true; } - // Warn about using one-shot iterators as children - const isOneShotIterator = - iteratorFn.call(newChildrenIterable) === newChildrenIterable; - if (isOneShotIterator) { - if (!didWarnAboutOneShotIterators) { - console.error( - 'Using a TOOD-understandable-term as children is unsupported and will likely yield ' + - 'unexpected results because enumerating a TOOD-understandable-term mutates it. ' + - 'You may convert it to an array with `Array.from()` or the ' + - '`[...spread]` operator before rendering. Keep in mind ' + - 'you might need to polyfill these features for older browsers.', - ); - } - didWarnAboutOneShotIterators = true; - } - // First, validate keys. // We'll get a different iterator later for the main pass. const newChildren = iteratorFn.call(newChildrenIterable); diff --git a/packages/react-reconciler/src/ReactChildFiber.old.js b/packages/react-reconciler/src/ReactChildFiber.old.js index 5f9d050452a25..a4f80d16f17e6 100644 --- a/packages/react-reconciler/src/ReactChildFiber.old.js +++ b/packages/react-reconciler/src/ReactChildFiber.old.js @@ -937,6 +937,22 @@ function ChildReconciler(shouldTrackSideEffects) { ); } didWarnAboutGenerators = true; + } else { + // Warn about using one-shot iterators as children + const isOneShotIterator = + iteratorFn.call(newChildrenIterable) === newChildrenIterable; + if (isOneShotIterator) { + if (!didWarnAboutOneShotIterators) { + console.error( + 'Using a TOOD-understandable-term as children is unsupported and will likely yield ' + + 'unexpected results because enumerating a TOOD-understandable-term mutates it. ' + + 'You may convert it to an array with `Array.from()` or the ' + + '`[...spread]` operator before rendering. Keep in mind ' + + 'you might need to polyfill these features for older browsers.', + ); + } + didWarnAboutOneShotIterators = true; + } } // Warn about using Maps as children @@ -950,22 +966,6 @@ function ChildReconciler(shouldTrackSideEffects) { didWarnAboutMaps = true; } - // Warn about using one-shot iterators as children - const isOneShotIterator = - iteratorFn.call(newChildrenIterable) === newChildrenIterable; - if (isOneShotIterator) { - if (!didWarnAboutOneShotIterators) { - console.error( - 'Using a TOOD-understandable-term as children is unsupported and will likely yield ' + - 'unexpected results because enumerating a TOOD-understandable-term mutates it. ' + - 'You may convert it to an array with `Array.from()` or the ' + - '`[...spread]` operator before rendering. Keep in mind ' + - 'you might need to polyfill these features for older browsers.', - ); - } - didWarnAboutOneShotIterators = true; - } - // First, validate keys. // We'll get a different iterator later for the main pass. const newChildren = iteratorFn.call(newChildrenIterable);