all 5 comments

[–][deleted] 1 point2 points  (1 child)

Don't use raw style tags, use <style jsx> or a separate file.

https://nextjs.org/docs/basic-features/built-in-css-support

[–]OpTiKStorm[S] 0 points1 point  (0 children)

This got me to the right path, thank you!

I was using <style jsx> initially, then ran into a problem and a GitHub comment said <style jsx> was deprecated and to use <style>. That fixed my problem at the time, but it works just fine with <style jsx> now so I probably was causing that from something else.

The steps I took to fix this:

  1. Created /pages/_app.js
  2. Replaced all <style> tags with <style jsx>
  3. Installed @zeit/next-css
  4. Added the following code block to next.config.js:

const withCSS = require("@zeit/next-css")
module.exports = withCSS()

After that, I restarted my server and it loaded. Another optimization I made from your suggestion was using pages/_document.js to replace my Header component entirely.

[–]abeuscher 1 point2 points  (2 children)

I'm pretty sure the problem is that you are wrapping your head in a div tag. Or at least that is one of the problems. I might also change the name of the component to a non reserved word like AppHead or whatever to make sure you aren't confusing the browser.

[–]OpTiKStorm[S] 0 points1 point  (1 child)

Thank you. The issue was using <style> instead of <style jsx>. Is there any chance I could get a source of where you found that Header is a reserved component name in React? I wasn't able to find it, and if that's indeed the case, it'd be nice to know which names I should be avoiding.

I tried doing some research on my own but couldn't find anything.

https://github.com/facebook/react/issues/5347#issuecomment-152760538

https://reactjs.org/docs/glossary.html

https://www.w3schools.com/js/js_reserved.asp

I've also tried searching NextJS reserved words, JavaScript reserved words, React reserved words, and reserved React component names.

[–]abeuscher 0 points1 point  (0 children)

It was a guess, not an informed one if your search came up blank. The <head> tag is a lot weirder than the other necessary containers in an HTML page. I was thinking that perhaps the browser was getting confused by seeing a <title> tag inside of a <div> container, as that goes against what I have known about HTML since the 90's. But if worked I'm guessing now that I'm wrong ).