Unverified Commit 23d71ff1 authored by Yossi Spektor's avatar Yossi Spektor Committed by GitHub

Any elements must be direct children of next/head (#11557)

It is any elements and not only meta or title because the children of next/head are generated in here: https://github.com/zeit/next.js/blob/8c899ee5e4cadc0a1cb47918613c1f6028b26314/packages/next/next-server/lib/head.tsx#L139
where React.cloneElement is called without the third parameter which is needed to clone the children as well (https://reactjs.org/docs/react-api.html#cloneelement).
parent bd85cbdf
...@@ -67,4 +67,5 @@ In this case only the second `<meta name="viewport" />` is rendered. ...@@ -67,4 +67,5 @@ In this case only the second `<meta name="viewport" />` is rendered.
> The contents of `head` get cleared upon unmounting the component, so make sure each page completely defines what it needs in `head`, without making assumptions about what other pages added. > The contents of `head` get cleared upon unmounting the component, so make sure each page completely defines what it needs in `head`, without making assumptions about what other pages added.
> `title` and `meta` elements need to be contained as **direct** children of the `Head` element, or wrapped into maximum one level of `<React.Fragment>`, otherwise the meta tags won't be correctly picked up on client-side navigations. `title`, `meta` or any other elements (e.g.`script`) need to be contained as **direct** children of the `Head` element,
or wrapped into maximum one level of `<React.Fragment>`, otherwise the tags won't be correctly picked up on client-side navigations.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment