ℹ️ There is an easy "workaround" you can apply instead of using React components, which are NOT supported within next/head as of NextJS 10.2
Fixes: #17721
Fixes: #17842
Essentially, >=9.5.4 breaks compatibility for having react components within Head. While it's true that NextJS never truly supported this...
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 or arrays—otherwise the tags won't be correctly picked up on client-side navigations.
...this is a fundamental React principle and we should support the concept of component composition. For example,
I tracked the issue to https://github.com/vercel/next.js/pull/16758/files#diff-f0591f99e1e66f02b12d5f64977b579eR86 where apparently we serialize head data in the window object now: window.__NEXT_DATA__, which doesn't handle components. I'm not sure the best way to handle that, but I created logic in head-manager.ts to handle react components and their potential children.
TODO
[x] Allow custom components in Head to not throw runtime errors (initial render/page load)
[ ] Allow custom components in Head to render on client navigation
[x] Update Tests
[x] Ensure component children aren't duplicated (only rendered once)
ℹ️ There is an easy "workaround" you can apply instead of using React components, which are NOT supported within next/head as of NextJS 10.2
Fixes: #17721 Fixes: #17842
Essentially, >=9.5.4 breaks compatibility for having react components within
Head
. While it's true that NextJS never truly supported this......this is a fundamental React principle and we should support the concept of component composition. For example,
I tracked the issue to https://github.com/vercel/next.js/pull/16758/files#diff-f0591f99e1e66f02b12d5f64977b579eR86 where apparently we serialize
head
data in the window object now:window.__NEXT_DATA__
, which doesn't handle components. I'm not sure the best way to handle that, but I created logic inhead-manager.ts
to handle react components and their potential children.TODO