Skip to content

Commit

Permalink
Move React Map child check to behind flags or __DEV__
Browse files Browse the repository at this point in the history
Revert other changes
  • Loading branch information
trueadm committed Feb 7, 2020
1 parent 256d78d commit 49f55ac
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions packages/react/src/ReactChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' +
Expand Down

0 comments on commit 49f55ac

Please sign in to comment.