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-manager: TypeError: Cannot read property 'content' of null #8220
Comments
On page, I have an svg logo image (simple img tag). It has some inline styles and some styles included from the scss file. Both places defined the max-width/height of the image. None works until i add Also can't find any documentation on why at _document Head is included as:
and in another place as:
this inside has link to next-server while {Head} from the next/document seems like has no link to next-server package.
|
Please follow the issue template and provide a full reproduction. |
the issue is that I didn't add head to _document but _app and other places. It would be awesome if that error would provide a hint that it needs to be in _document only. also, this definitely should be somewhere in the documentation:
|
To add/respond to @liesislukas, I looked into this a bit more at the code level, and the reason this is all happening (I missed it too!) is that the base The doc https://nextjs.org/docs#custom-document has a very good example to build upon and has the line:
Also in that example, there's the import
Once I utilized and imported properly, the error went away. TLDR - If you create a _document.jsx at all, ensure it's actively using the correctly imported elements named above to render your own custom doc. (@timneutkens your comment was absolutely correct but I feel the doc reference may help further) |
Seems reasonable that this should just warn. I’ll put up a PR later today |
It's actually not put under body, you're injecting invalid html ( |
Just my 2 cents, but I think a better solution for all this is a warning if next finds that the _document.tsx doesn't have the expected (and properly imported) React components in the template. I appreciate the PR (#8276) but I feel the warning output is too low level for the actual dev to realize how to fix it. Alternatively, maybe this could be an eslint plugin rule, if there's any thought to creating a plugin... |
I found this error at nextjs antd-mobile example. // examples/with-antd-mobile/pages/_app.js
<Head>
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
/>
<style global jsx>{`
html,
body {
font-family: 'Helvetica Neue', 'Hiragino Sans GB', Helvetica, 'Microsoft YaHei', Arial;
margin: 0;
}
`}</style>
</Head> |
head-manager.ts:52 Uncaught (in promise) TypeError: Cannot read property 'tagName' of null --I solve this problem by remove this line<style id="jss-server-side"></style>in <Header> => next/head |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
tried to isolate the issue and find when it happens. I removed all the surrounding code from _app.js
and InitialHead works perfectly fine, it's code:
The title is updated to "Foo"
"next": "^9.0.3",
macos 10.14.6
Chrome Version 76.0.3809.87 (Official Build) (64-bit)
The text was updated successfully, but these errors were encountered: