From c55c34e46a6d8148afb78594d14f4675f9346900 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Fri, 7 Feb 2020 12:21:50 +0000 Subject: [PATCH] Move React Map child check to behind flags or __DEV__ (#17995) --- packages/react/src/ReactChildren.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/react/src/ReactChildren.js b/packages/react/src/ReactChildren.js index 9329d89c57c16..6e65fd8ddcde9 100644 --- a/packages/react/src/ReactChildren.js +++ b/packages/react/src/ReactChildren.js @@ -159,17 +159,18 @@ function traverseAllChildrenImpl( } else { const iteratorFn = getIteratorFn(children); if (typeof iteratorFn === 'function') { - if (iteratorFn === children.entries) { - if (disableMapsAsChildren) { - invariant( - false, - 'Maps are not valid as a React child (found: %s). Consider converting ' + - 'children to an array of keyed ReactElements instead.', - children, - ); - } + if (disableMapsAsChildren) { + invariant( + iteratorFn !== children.entries, + 'Maps are not valid as a React child (found: %s). Consider converting ' + + 'children to an array of keyed ReactElements instead.', + children, + ); + } + + if (__DEV__) { // Warn about using Maps as children - if (__DEV__) { + if (iteratorFn === children.entries) { if (!didWarnAboutMaps) { console.warn( 'Using Maps as children is deprecated and will be removed in ' +