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
[Feature request] Improved suggestion for invalid element type #9231
Comments
Thanks for the issue @nycdotnet! Welcome to the React community ⚛️ That's definitely one scenario where the warning may not be as helpful. But since there's usually only a single If we can verify that more new users experience this specific issue than we can definitely consider it, but as it stands I think this is an edge case that might distract from the most common case and confuse some new React developers. Maybe |
Thanks for considering this. |
Seems like we haven't seen much confusion in this area so it's probably not worth spending extra doc or warning space on this (and thus confusing people who don't have this problem but have more common ones). |
Thank you for the consideration. |
This is a feature request.
Current behavior:
If
ReactDOM.render()
is called using a component name that is declared later in the same file, the resulting error suggests that the component wasn't exported from the file it was defined in.Example code where the suggestion is inappropriate:
What is the expected behavior?
The suggestion does not help in this instance. It would be helpful if the error message also suggested that ReactDOM.render() may have been called too early. For example:
I am an experienced ES6+ developer, but new to React. I just finished the tic-tac-toe tutorial and was attempting to apply what I had learned to one of my web sites when I made the above mistake. Since this mistake is plausible to be made by someone just getting started (especially if they are taking the tutorial code as their starting point, and are new to ES6+), it would be useful to suggest the alternate possible fix. It might help other beginners out there.
If this is OK, I'll send a PR ASAP. Thank you for your consideration.
This is on the latest version of React and should affect all environments. Thank you.
The text was updated successfully, but these errors were encountered: