-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Styles do not get applied from _document.js with getInitialProps are called #1035
Comments
Can validate that this occurs with |
Duplicate of #885 |
@timneutkens this is not a duplicate. These styles are not within the |
From Arunoda's reply on that ticket:
From my reply on that ticket:
The issue here is that you're using styled-jsx inside of |
Ok that makes sense. Thank you very much I understand now.
…On Feb 8, 2017, 7:53 AM -0600, Tim Neutkens ***@***.***>, wrote:
From Arunoda's reply on that ticket:
>
> Not exactly sure about how this happens.
> But you should not styles like this with the custom document.
> Whole purpose of the custom document should to customize your HTML page. Inside the custom layout, we don't have access to the React app.
> So, try to move your styles to a common layout.
> See this related discussion: #873 (#873) (comment)
>
From my reply on that ticket:
>
> <style>{.welcome { color: red; }}</style> will be global. Using just the <style> fixes your issue 👍
>
The issue here is that you're using styled-jsx inside of <Document /> also, <Document /> is not hot reloaded by design afaik. The way to go here as Arunoda said is using a layout HOC: https://github.com/zeit/next.js/tree/master/examples/layout-component
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub (#1035 (comment)), or mute the thread (https://github.com/notifications/unsubscribe-auth/ABwmA0mnxP2fWpmdr3wik1g2uiqO3MSeks5racjigaJpZM4L607a).
|
Sorry for closing it without the actual explanation 😅 |
As of next version
"next": "^2.0.0-beta.22"
Whenever you use a
_document.js
fragment to overwrite the default construction of the page document, styles are not applied whengetInitialProps()
is used.If you comment out
getInitialProps()
, then styles will be applied. They DO NOT however hot load, and require a page refresh. Change to use<styled jsx global>
does not resolve issue.Expected that
styled jsx
applies styles (global or not) regardless of the use ofgetInitalProps()
. Also expected to hot load like any other page in the application.The text was updated successfully, but these errors were encountered: