Skip to content

Commit

Permalink
Move React Map child check to behind flags or __DEV__ (#17995)
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm authored Feb 7, 2020
1 parent 901d76b commit c55c34e
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 c55c34e

Please sign in to comment.