-
Notifications
You must be signed in to change notification settings - Fork 47.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw more specific error if passed undefined in React.cloneElement #12534
Changes from 3 commits
7bc5fd5
8ee2452
33d1edf
48c7b53
34816fc
2733707
44df599
7f6d18b
baa4d84
80de944
e3416ee
905abfc
d20de72
070ef20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,6 +290,11 @@ export function cloneAndReplaceKey(oldElement, newKey) { | |
* See https://reactjs.org/docs/react-api.html#cloneelement | ||
*/ | ||
export function cloneElement(element, config, children) { | ||
|
||
if (!element) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's be more specific here. Only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it’s basically a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One error for both cases is fine |
||
throw new TypeError('Cannot clone null or undefined.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the rest of the codebase we use a function called invariant(false, 'message') There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that’s really cool, I’ll put that in there |
||
} | ||
|
||
let propName; | ||
|
||
// Original props are copied | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: extra line