-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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 when you've forgotten to extend React.Component #10103
Comments
Note that the error is much worse when you're compiling classes without |
Thanks for the feature request @thejameskyle! I agree that a better error here would provide a better developer experience. It also looks like Fiber will get caught in an infinite loop if you try to render a class that doesn't extend Here's an example demonstrating that. Be warned, it will crash or freeze your browser/tab.Click at your own risk
|
The infinite loop is a known issue with error handling. |
Will fix before release |
Thanks, @acdlite! Do you know if the fix will address @thejameskyle's request? Or would a better error for non-extending classes be orthogonal to your error handing fix? |
Yeah, fixing the infinite loop bug would not address the lack of a helpful error message. Good candidate for an external PR. Should also account for |
gonna give it a shot... first contribution |
i am a bit confused. |
That logic is now in |
Ok I think I have a good handle on this. Upon deeper inspection the error happens earlier in the lifecycle than in (The error actually gets thrown in As for what to check, i'm going with simply |
for anyone else watching we made this into a |
Fixed in #11168. |
When you forget to extend
React.Component
you get the following error:[Example]
It would be nice if in dev you could do a check for
Component.prototype.render
and if it exists, provide a better warning along the lines of:I believe it would happen in ReactCompositeComponent.js.
The text was updated successfully, but these errors were encountered: