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

Styled-components FOUC with nextjs and typescript #4782

Closed
scottdj92 opened this issue Jul 14, 2018 · 2 comments
Closed

Styled-components FOUC with nextjs and typescript #4782

scottdj92 opened this issue Jul 14, 2018 · 2 comments
Labels
good first issue Easy to fix issues, good for newcomers

Comments

@scottdj92
Copy link

Bug report

Describe the bug

Hi, there seems to be FOUC when attempting to render styled components server-side.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Go to https://github.com/scottdj92/next-styled-components-fouc
  2. Clone, install, run npm run dev with the dev tools open
  3. See that the index route doesn't render styles server side
  4. Further inspection (console logging) of _document.tsx's styleTags prop returns undefined

Expected behavior

I expected style tags to be rendered server side with TS. I ran the same repo without TS, and it behaved as expected.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: OS X
  • Browser (if applies) FF Quantum & Chrome 67
  • Version of Next.js: ^6.1.1

Screenshot

screen shot 2018-07-14 at 9 13 56 am

Additional Questions

Would this be solved by moving this to _app.js? I don't see anything in the docs that say so. If the examples need to be updated, I'd be willing to do that :)

@timneutkens timneutkens added help wanted good first issue Easy to fix issues, good for newcomers labels Jul 14, 2018
@brainkim
Copy link
Contributor

Ran into this myself. getInitialProps in your example should be static or it won’t run. Maybe next.js could emit a warning when getInitialProps is defined non-statically?

@scottdj92
Copy link
Author

scottdj92 commented Jul 16, 2018

Ooo that's a nice catch, I didn't see that.

EDIT: yep, adding static to the getInitialProps declaration fixes my issue in the example repo. We should add a warning in the CLI that notifies the developer if getInitialProps is defined non-statically like @brainkim mentioned.

HaNdTriX added a commit to HaNdTriX/next.js that referenced this issue Aug 8, 2018
Ommitting the static keyword happens pretty often. Therefore we should warn the devloper in devmode.

Closes: vercel#4782
HaNdTriX added a commit to HaNdTriX/next.js that referenced this issue Aug 8, 2018
Omitting the static keyword happens pretty often. Therefore we should trigger a warning in devmode.

Closes: vercel#4782
HaNdTriX added a commit to HaNdTriX/next.js that referenced this issue Aug 8, 2018
Omitting the static keyword happens pretty often. Therefore we should trigger a warning in devmode.

Closes: vercel#4782
HaNdTriX added a commit to HaNdTriX/next.js that referenced this issue Aug 8, 2018
Omitting the static keyword happens pretty often. Therefore we should trigger a warning in devmode.

Closes: vercel#4782
HaNdTriX added a commit to HaNdTriX/next.js that referenced this issue Aug 8, 2018
Omitting the static keyword happens pretty often. Therefore we should trigger a warning in devmode.

Closes: vercel#4782
HaNdTriX added a commit to HaNdTriX/next.js that referenced this issue Aug 8, 2018
Omitting the static keyword happens pretty often. Therefore we should trigger a warning in devmode.

Closes: vercel#4782
HaNdTriX added a commit to HaNdTriX/next.js that referenced this issue Aug 8, 2018
Omitting the static keyword happens pretty often. Therefore we should trigger a warning in devmode.

Closes: vercel#4782
HaNdTriX added a commit to HaNdTriX/next.js that referenced this issue Aug 9, 2018
Omitting the static keyword happens pretty often. Therefore we should trigger a warning in devmode.

Closes: vercel#4782
@lock lock bot locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants