-
Notifications
You must be signed in to change notification settings - Fork 27.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
Fragments not supported in <Head /> #3399
Comments
Confirm same behavior, it seems to be only emptying the |
Actually what's happening inside In this case, we only see the So, with conditional logic, you can as have as many as But if someone willing to add |
Hey, diff --git a/lib/head.js b/lib/head.js
index 3473332..e9842f8 100644
--- a/lib/head.js
+++ b/lib/head.js
@@ -21,6 +21,12 @@ function reduceComponents (components) {
.map((c) => c.props.children)
.map((children) => React.Children.toArray(children))
.reduce((a, b) => a.concat(b), [])
+ .reduce((a, b) => {
+ if (React.Fragment && b.type === React.Fragment) {
+ return a.concat(React.Children.toArray(b.props.children))
+ }
+ return a.concat(b)
+ }, [])
.reverse()
.concat(...defaultHead())
.filter((c) => !!c) This makes code posted by tusbar work without problems. This doesn't change current logic much - it's still reading direct children (so no nested Fragments). Is it kind of solution you are looking for? If it is I'm happy to take this issue and create PR. |
@Sekhmet that looks good. :) Open that PR, it’ll get more visibility. |
Expected Behavior
Considering the following snippet:
When
title
is defined, I would expect<title>foo | Cool site</tite>
to be rendered.Current Behavior
An empty
<title />
is rendered.Your Environment
The text was updated successfully, but these errors were encountered: