-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Returning an empty fragment throws a confusing error #12964
Labels
Comments
This also doesn't throw when using |
I think that's just a bug. |
So rendering empty fragments should work? |
philipp-spiess
added a commit
to philipp-spiess/react
that referenced
this issue
Jun 2, 2018
Fixes facebook#12964 When a fragment is reconciled, we directly move onto it’s children. Since an empty `<React.Fragment/>` will have children of `undefined`, this would always throw. To fix this, we bail out in those cases. This case now behaves like returning `null` directly.
philipp-spiess
added a commit
to philipp-spiess/react
that referenced
this issue
Jun 2, 2018
Fixes facebook#12964 When a fragment is reconciled, we directly move onto it’s children. Since an empty `<React.Fragment/>` will have children of `undefined`, this would always throw. To fix this, we bail out in those cases. This case now behaves like returning `null` directly.
Fixed in React 16.4.1. |
For posterity, #12964 (comment) was caused by |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://codesandbox.io/s/40j50607y0
Rendering a component like:
Throws the error:
The error is confusing because clearly
Foo
is returning a value. I don't know if we want to support rendering empty fragments, but in any case this error is confusing.If this isn't allowed it should explicitly call out that a component cannot return a fragment with no children.
cc @gaearon
The text was updated successfully, but these errors were encountered: