@samitouri / QOS-React / commits / c55c34e46a

Move React Map child check to behind flags or __DEV__ (#17995)

Dominic Gannaway committed Feb 7, 2020 at 12:21 UTC c55c34e46a6d8148afb78594d14f4675f9346900
1 file changed +11 -10
packages/react/src/ReactChildren.js
+11 -10
@@ -159,17 +159,18 @@ function traverseAllChildrenImpl(
159 } else {
160 const iteratorFn = getIteratorFn(children);
161 if (typeof iteratorFn === 'function') {
162 - if (iteratorFn === children.entries) {
163 - if (disableMapsAsChildren) {
164 - invariant(
165 - false,
166 - 'Maps are not valid as a React child (found: %s). Consider converting ' +
167 - 'children to an array of keyed ReactElements instead.',
168 - children,
169 - );
170 - }
162 + if (disableMapsAsChildren) {
163 + invariant(
164 + iteratorFn !== children.entries,
165 + 'Maps are not valid as a React child (found: %s). Consider converting ' +
166 + 'children to an array of keyed ReactElements instead.',
167 + children,
168 + );
169 + }
170 +
171 + if (__DEV__) {
172 // Warn about using Maps as children
172 - if (__DEV__) {
173 + if (iteratorFn === children.entries) {
174 if (!didWarnAboutMaps) {
175 console.warn(
176 'Using Maps as children is deprecated and will be removed in ' +