-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
<Head> do not work as expected if not at the document/page level #5038
Comments
I wonder if this bug could be related to some older issues reported: |
Could you create a minimal reproduction in a GitHub repository? Thanks 🙏 |
Hey Simon, |
@timneutkens oops, posted that by mistake. I'll try to provide you with an minimal reproduction. Can't use npm right now because of an SSL certificate issue, I'll try to get something working as soon as possible. |
Great! Thanks 🙏 |
@timneutkens okay, got a repro pushed here: https://github.com/SBoudrias/bug-next-head In this minimal reproduction, a green box will appear properly with Next 6, but it doesn't show with Next 7. |
@SBoudrias amazing reproduction, that you very much, this allowed me to track it down way faster. I've also used the reproduction as the test to see if it works correctly: https://github.com/zeit/next.js/pull/5068/files#diff-5fa00d00bca1d3713b89864f75f55750 This PR should fix exactly what you were experiencing. |
Awesome! Thanks a lot for looking into this :) |
Fixes #5038 The problem with `constructor` is that it doesn't have `context` yet when being called. It's also considered unsafe to add a side-effect on constructor except when server-rendering
Bug report
Describe the bug
I think this is a regression caused by the refactor inside #5020 (v7 canary-3). We tested going back to
canary-1
and the bug wasn't there.Basically, the issue is that
style
elements (withkey
) inside a<Head>
that is not injected in the_document.js
file or thepages/*
level are not working.The issue seems to be quite consistent per pages, but not consistent per types of components. Sometime it work and sometime it doesn't. The only place it seemed to consistently failed was inside
dynamic()
components.Expected behavior
next/head
should always inject the content in the head of the page no matter where it's been called (dynamic imports, portals, component level, etc)System information
The text was updated successfully, but these errors were encountered: