Skip to content
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

Better error message on ReactElementValidator type error #7485

Closed
Wilfred opened this issue Aug 12, 2016 · 2 comments
Closed

Better error message on ReactElementValidator type error #7485

Wilfred opened this issue Aug 12, 2016 · 2 comments

Comments

@Wilfred
Copy link

Wilfred commented Aug 12, 2016

Currently, createElement throws the warning:

Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components).

It would be more helpful if the warning actually said what value was passed, e.g.:

Warning: React.createElement: 5 is an invalid value for type. It should be a string (for DOM elements) or a ReactClass (for composite components).

@aweary
Copy link
Contributor

aweary commented Aug 12, 2016

Thanks for the issue @Wilfred! We agree that the message is lacking, and as luck would have it we're already tracking this in #7307. There's a PR open (#7402) to improve the message by linking to a more descriptive doc, and I think we're going to try to include this kind of info in the warning as well if we can.

I'm going to close this as duplicate, so feel free to subscribe to #7307 and #7402 and provide input there.

@aweary aweary closed this as completed Aug 12, 2016
@edvinerikson
Copy link
Contributor

IMO Not sure it will help that much to print the actual value. Most cases when I hit this error or get questions about it, it's mostly caused by undefined because of a faulty component require/export.

Ideally I would like it to log in which component the error occurred and also maybe point out that if the value is undefined tell you to check your component requires/exports.

If the value isn't undefined then it may be nice to log the value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants