Skip to content

Commit

Permalink
Avoid .valueOf to close #20594 (#20617)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaqq authored Jan 20, 2021
1 parent 2a646f7 commit 2e948e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/react-reconciler/src/ReactChildFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,15 @@ function coerceRef(

function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) {
if (returnFiber.type !== 'textarea') {
const childString = Object.prototype.toString.call(newChild);
invariant(
false,
'Objects are not valid as a React child (found: %s). ' +
'If you meant to render a collection of children, use an array ' +
'instead.',
Object.prototype.toString.call(newChild) === '[object Object]'
childString === '[object Object]'
? 'object with keys {' + Object.keys(newChild).join(', ') + '}'
: newChild,
: childString,
);
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/react-reconciler/src/ReactChildFiber.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,15 @@ function coerceRef(

function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) {
if (returnFiber.type !== 'textarea') {
const childString = Object.prototype.toString.call(newChild);
invariant(
false,
'Objects are not valid as a React child (found: %s). ' +
'If you meant to render a collection of children, use an array ' +
'instead.',
Object.prototype.toString.call(newChild) === '[object Object]'
childString === '[object Object]'
? 'object with keys {' + Object.keys(newChild).join(', ') + '}'
: newChild,
: childString,
);
}
}
Expand Down

0 comments on commit 2e948e0

Please sign in to comment.