Skip to content
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

"Component definition is missing display name" Next.js build fail using code from docs #3584

Closed
tr1s opened this issue Sep 19, 2021 · 2 comments

Comments

@tr1s
Copy link

tr1s commented Sep 19, 2021

A recent update in my npm packages (probably from Next.js) has caused build failures.

The code styled-components provides in the docs that you add to _document.js in order for styled-components to work in a Next.js project is no longer working.

I can't figure out how to fix this code even when looking at the react/display-name rules. Any help would be appreciated, thank you!

The error I get in vercel:

CleanShot 2021-09-18 at 21 13 24@2x

What the error looks like in my code:

CleanShot 2021-09-18 at 21 01 36@2x

These are the package updates I made that caused the sudden build failure:

CleanShot 2021-09-18 at 21 24 54@2x

@tr1s tr1s changed the title "Component definition is missing display name" Next.js build fail using codes from docs "Component definition is missing display name" Next.js build fail using code from docs Sep 19, 2021
@kitten
Copy link
Member

kitten commented Sep 19, 2021

Just make sure to assign the function that is highlighted to a named variable and return it.
some notes on that 😅

  • This is a linting rule and I'm not sure why Next.js is failing your build and if that's their default, but it's not a build error or even an error in general
  • This isn't something that is related to styled-components per se, so you may want to ask on the Next.js repo whether the example needs updating there too and why a linting rule errors. Again, not sure if that's because of your setup 😃
  • Last point, promised 😅 This would still then be neither a bug or an issue with styled-components. It's either a usage question (so for StackOverflow and the likes) or an issue for the docs, which is in the styled-components-website repo

anyway, we'll see!

@tr1s
Copy link
Author

tr1s commented Sep 19, 2021

Yeah my mistake, I thought there might have been some update that styled-components didn't document.

For anyone who stumbles upon this:

I tried to name the component but that didn't work. Turns out it 's an eslint-config-next issue and downgrading from 11.2.1 to 11.1.0 did the trick.

@tr1s tr1s closed this as completed Sep 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants