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

Add a more helpful message when passing an element to createElement() as a type #13130

Closed
gaearon opened this issue Jun 30, 2018 · 2 comments
Closed

Comments

@gaearon
Copy link
Collaborator

gaearon commented Jun 30, 2018

This:

createElement(<div />)

doesn't currently give a distinguishable message.

https://stackoverflow.com/questions/51110436/wrapping-provider-in-same-component-throws-element-type-is-invalid-expected-a-s

But we can easily detect it by checking for $$typeof and in that case suggest something more concrete (e.g. "Did you accidentally export JSX instead of a component?").

@DCtheTall
Copy link
Contributor

I can take this one!

@aweary
Copy link
Contributor

aweary commented Jun 30, 2018

It's all yours @DCtheTall!

gaearon pushed a commit that referenced this issue Aug 1, 2018
* [#13130] Add a more helpful message when passing an element to createElement()

* better conditional flow

* update after review

* move last condition inside last else clause

* Added test case

* compare 25132typeof to REACT_ELEMENT_TYPE

* runs prettier

* remove unrelated changes

* Tweak the message
segoddnja pushed a commit to segoddnja/react that referenced this issue Aug 1, 2018
…book#13131)

* [facebook#13130] Add a more helpful message when passing an element to createElement()

* better conditional flow

* update after review

* move last condition inside last else clause

* Added test case

* compare 25132typeof to REACT_ELEMENT_TYPE

* runs prettier

* remove unrelated changes

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

No branches or pull requests

3 participants