<style jsx> cannot render in next/head
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 16.16.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 12.3.2-canary.26
eslint-config-next: 12.1.0
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
cannot render in next/head<Head>
...
<style jsx>{`
body {
margin: 0;
background: #ccc;
}
`}</style>
</Head>
Expected Behavior
render in next/head successfullyLink to reproduction
https://github.com/Capricair/next-dynamic-issue
To Reproduce
- npm run install
- npm run dev
- open homepage
Have you tried the global flag on the style tag?
If you just want to add a style tag in Next/Head, you can just remove jsx prop.
If you want to add jsx style globally, you need to move this style tag out of Head component, do something like this:
https://nextjs.org/blog/styling-next-with-styled-jsx
(you can also refer to here: https://github.com/vercel/styled-jsx)
But I cannot find the reason why jsx style tag be omitted in Head component. Not sure if anyone can point out that.
If you just want to add a style tag in Next/Head, you can just remove
jsxprop. If you want to add jsx style globally, you need to move this style tag out of Head component, do something like this: https://nextjs.org/blog/styling-next-with-styled-jsx (you can also refer to here: https://github.com/vercel/styled-jsx) But I cannot find the reason whyjsxstyle tag be omitted in Head component. Not sure if anyone can point out that.
Next.js includes Styled JSX by default
Have you tried the
globalflag on the style tag?
global flag also doesn't work