-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
[Fiber] returning functions from render does not throw #9577
Comments
Looks like a bug. Why does it happen? |
It looks like It does also check for |
Warning, the link below will cause an infinite loop and might crash the tab/browser @gaearon Here's an example showing that returning I can open a separate issue for this if you'd like |
Got it, thanks. As for the function issue, I think this would be fixed if those invariant checks in |
Right now we treat unknown types as empty. We have a special case for |
One disadvantage to throwing versus warning is that it requires an extra check in production, for null. EDIT: I guess we already do a null check |
I think using just a warning would make it too easy for components to silently fail. Existing behavior is to throw as well. The validation logic is already in the bundle, it's just dead code right now. Can we safely move it outside of the |
I was actually about to ask if we could make this type of render work? I have various components (Foo, Goo, Hoo, etc.) that I need to conditionally render. Right now I use
if
|
@HunderlineK You can just wrap it in |
I made a list of different things which I think we should (dis)allow as return values.
The ones with asterisk are the ones we currently silently skip (but used to error on). The ones with two asterisks are the ones we always skipped. IMO we should at least warn about them. Need to evaluate how many more conditions this would add. We probably need to start with warnings anyway because we might already happen to rely on some of them at FB since we enabled new features a while ago. I only feel strongly about |
Since |
https://jsfiddle.net/3apqnhmw/
When
App
returnsFoo
instead of<Foo />
accidentally, Fiber does not catch this.The text was updated successfully, but these errors were encountered: