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

No styles at all in next SSR with react 18 and next 12.1.6 #82

Closed
bdew opened this issue May 6, 2022 · 10 comments
Closed

No styles at all in next SSR with react 18 and next 12.1.6 #82

bdew opened this issue May 6, 2022 · 10 comments

Comments

@bdew
Copy link

bdew commented May 6, 2022

I don't know if it's related to whatever was fixed in #78 but after this update I'm not getting almost any styles (neither MUI default nor useStyles) in SSR.

The only styles coming from SSR are those 2 small snippets

image

After hydration it fixes itself and looks correct. Also doesn't seem to happen with react 17.

Example repo: https://github.com/bdew/sqp

@bdew
Copy link
Author

bdew commented May 6, 2022

The demo in https://github.com/garronej/tss-react/tree/main/src/test/apps/ssr has the same problem (if i update its dependencies so it runs on react 18)

image

@bdew
Copy link
Author

bdew commented May 6, 2022

Looks like it's already reported in next vercel/next.js#36675 - sorry only found the other bug after submitting this one.

@garronej
Copy link
Owner

garronej commented May 6, 2022

@bdew Thank you very much for pointing this out.

The silly reason why I considered Next SSR fixed is because I updated the dependency on the wrong demo project.

image

Thanks for digging out the issue on Next's repo!

I have notifier @mui that Next SSR is still broken

Since the problem is not directly related to tss-react but to Next.js + Emotion with manual configuration of SSR I will wait for a solution to be found by the main tenant.

Thanks for the detailed report,

Best regards,

@AntonOfTheWoods
Copy link

Sorry to butt in on a subject I don't really understand, but is this related to the same problem as mentioned here? (and which jss has probably fixed with this)

@garronej
Copy link
Owner

garronej commented May 8, 2022

Hi @AntonOfTheWoods, thanks for your input,
Yes it has to do with this but I think it's more specifically this.
TSS is a wrapper around @emotion/react and @emotion/react is the style engine used behind the scene by MUI.
I don't think I should attempt to fix it specifically for TSS, I should wait to see how emotion/MUI/Next.js decide to go about the issue.
Currently, MUI provide no working configuration that works with Next.js + React 18.
See this issue (it should be reopened Monday).

As soon as a solution is found you can rest assured that I will update "tss-react/nextJs" if nessesary and/or update the doc.

Thanks for reaching out,

@AntonOfTheWoods
Copy link

Thanks @garronej . Actually I am (was!) just using StrictMode with normal React 18 and the latest MUI, not using next or SSR at all. In dev mode with StrictMode lots of stuff is broken, without StrictMode most stuff seems to work ok. There are a few other things that have changed but that might be just related to migrating to tss-react (stuff like "& svg": ... working a little differently in certain circumstances but not all...). I am migrating react-admin to 4, MUI to 5.6 and React to 18, so lots of stuff has little niggles but that is totally expected.

My understanding is that in dev mode they are running something twice, which means several css-in-jss solutions have issues. Is this a different issue, or the same underlying one?

@garronej
Copy link
Owner

garronej commented May 9, 2022

@AntonOfTheWoods,
thanks for reporting.
I am unaware of any issue outside of SSR in Next.js with React 18.
I have tested the test SPA create-react-app with React 18 and <StrictMode /> and everything is working as expected.
If you can come up with a specific reproducible issue, I will happily address it. Ideally, that would be under the form of a testable repo.

@AntonOfTheWoods
Copy link

AntonOfTheWoods commented May 11, 2022

Actually @garronej it looks like I may have made a false accusation there. Adding StrictMode back after fixing a few other things (like nested selectors) has got things working. The nested selectors thing is clearly documented though so I guess I was just getting confused. Thanks for your help on this!

@garronej
Copy link
Owner

@AntonOfTheWoods Thank you very much for taking the time to give feedback. Much appreciated!

@garronej
Copy link
Owner

Working with Next.js v12.1.7-canary.4 🥳

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

3 participants