-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Improve error messages for invalid element types #8612
Conversation
9d2d815
to
940f820
Compare
warning( | ||
false, | ||
'React.createElement: type is invalid -- expected a string (for ' + | ||
'built-in components) or a class/function (for composite ' + |
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: we don't use "composite" in docs much, maybe "user-defined"?
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.
"custom components" ?
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.
Custom components makes me think of web components (custom web elements). I think user-defined sounds better 👍
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.
Should “composite components” start becoming part of normal React users lexicon? Even though it may be a bit foreign when a developer first sees and experiences it, it can present an opportunity to start learning about Composite and Host components and how React models things a bit more.
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.
Just keeping what was already there…
'ReactClass (for composite components).' | ||
'Warning: React.createElement: type is invalid -- expected a string ' + | ||
'(for built-in components) or a class/function (for composite ' + | ||
'components) but got: undefined.' |
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.
Maybe it would be nice to also add the export warning for undefined
, since trying to import a named export that doesn't exist will return undefined
and I think that's probably a common mistake too. Especially when using third party libraries.
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.
lgtm. I agree that undefined
should use this addendum as well like @aweary said above.
940f820
to
1846708
Compare
(cherry picked from commit eca5b1d)
cc @mkonicek https://twitter.com/martinkonicek/status/810917317639110661