-
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
getInitialProps
in _document
does not produce server-side styled-components
styles
#35758
Closed
1 task done
Labels
bug
Issue was opened via the bug report template.
Comments
1 task
kachkaev
changed the title
getInitialProps in _document remains broken in 12.1.3
Mar 30, 2022
getInitialProps
in _document
does not produce server-side styled-component
styles
kachkaev
changed the title
Mar 30, 2022
getInitialProps
in _document
does not produce server-side styled-component
stylesgetInitialProps
in _document
does not produce server-side styled-components
styles
kodiakhq bot
pushed a commit
that referenced
this issue
Mar 31, 2022
This is a follow-up to #35736 that ensures we use the styles from `_document.getInitialProps` instead of only applying the `styled-jsx` styles. ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` Fixes: #35758 x-ref: #35736
Hi, this has been updated in the latest version of Next.js |
Thank you for releasing the fix so quickly! I upgraded to |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
pavleadev
added a commit
to pavleadev/next.js
that referenced
this issue
Mar 29, 2023
This is a follow-up to vercel/next.js#35736 that ensures we use the styles from `_document.getInitialProps` instead of only applying the `styled-jsx` styles. ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` Fixes: vercel/next.js#35758 x-ref: vercel/next.js#35736
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Verify canary release
(12.1.3 is the latest release at the time of writing)
Provide environment information
What browser are you using? (if relevant)
N/A
How are you deploying your application? (if relevant)
N/A
Describe the Bug
This bug is very similar to what has already been described in #35711 and fixed in #35736. Upgrading Next from 12.1.1 to 12.1.3 breaks SSR in
styled-components
when using React 18. Initial styles are missing in page source, as ifgetInitialProps
in_document
have not been called.This may be to do with hydration too (not sure).
Expected Behavior
I expect no initial flickering in styles when opening a server-side-rendered page.
To Reproduce
yarn create next-app --example with-styled-components with-styled-components-app
Upgrade React to
18.0.0
Run
yarn dev
Open
view-source:http://localhost:3000
Observe that there is no style tag
<style data-styled="" data-styled-version="5.3.5">...</style>
. The whole page source fits one line.Downgrade Next from
12.1.3
to12.1.2
and confirm the same behavior.Downgrade Next from
12.1.2
to12.1.1
, openview-source:http://localhost:3000
and observe the style tag. The source will span across five lines. This is expected.The example is too small to observe the actual style flickering, but it is noticeable in a real Next.js app.
Relevant example code:
next.js/examples/with-styled-components/pages/_document.js
Lines 5 to 29 in 9f9214a
The text was updated successfully, but these errors were encountered: