GeezerVison is showing github.com — Avoid .valueOf to close #20594 (#20617) · react/react@2e948e0
File tree
Expand file treeCollapse file tree
Open diff view settings
packages/react-reconciler/src
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactChildFiber.new.js +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -222,14 +222,15 @@ function coerceRef( |
222 | 222 |
|
223 | 223 | function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) { |
224 | 224 | if (returnFiber.type !== 'textarea') { |
| 225 | + const childString = Object.prototype.toString.call(newChild); |
225 | 226 | invariant( |
226 | 227 | false, |
227 | 228 | 'Objects are not valid as a React child (found: %s). ' + |
228 | 229 | 'If you meant to render a collection of children, use an array ' + |
229 | 230 | 'instead.', |
230 | | - Object.prototype.toString.call(newChild) === '[object Object]' |
| 231 | + childString === '[object Object]' |
231 | 232 | ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' |
232 | | - : newChild, |
| 233 | + : childString, |
233 | 234 | ); |
234 | 235 | } |
235 | 236 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactChildFiber.old.js +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -222,14 +222,15 @@ function coerceRef( |
222 | 222 |
|
223 | 223 | function throwOnInvalidObjectType(returnFiber: Fiber, newChild: Object) { |
224 | 224 | if (returnFiber.type !== 'textarea') { |
| 225 | + const childString = Object.prototype.toString.call(newChild); |
225 | 226 | invariant( |
226 | 227 | false, |
227 | 228 | 'Objects are not valid as a React child (found: %s). ' + |
228 | 229 | 'If you meant to render a collection of children, use an array ' + |
229 | 230 | 'instead.', |
230 | | - Object.prototype.toString.call(newChild) === '[object Object]' |
| 231 | + childString === '[object Object]' |
231 | 232 | ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' |
232 | | - : newChild, |
| 233 | + : childString, |
233 | 234 | ); |
234 | 235 | } |
235 | 236 | } |
|