vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.89k stars 26.87k forks source link

<style jsx> cannot render in next/head #41382

Open Capricair opened 2 years ago

Capricair commented 2 years ago

Verify 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 ``` ... ``` ### Expected Behavior render in next/head successfully ### Link to reproduction https://github.com/Capricair/next-dynamic-issue ### To Reproduce 1. npm run install 2. npm run dev 3. open homepage
chriseagle commented 1 year ago

Have you tried the global flag on the style tag?

teobler commented 1 year ago

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.

Capricair commented 1 year ago

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.

Next.js includes Styled JSX by default

Capricair commented 1 year ago

Have you tried the global flag on the style tag?

global flag also doesn't work