-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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 not applied in first load using Material-UI & Next.js [@mui/styles] #29637
Comments
@hbjORbj I have updated the link to use codesandbox instead. |
@shorcy the SSR configuration is not complete. As you are using both
Make sure to combine both implementations. Are you intentionally using both JSS and emotion? I would recommend using only emotion, for overrides you can use the |
I am closing the issue. Instructions for fixing it were provided. If there is another issue feel free to re-open. |
After spending a lot of time updating the repo to use SX prop and updating _app and _document to use emotion cache instead. I still be having the same issue now just with different colors. But the issue is now only visible on the live site (Hosted with vercel). |
I had the same problem, How did I fix it? Just don't use makeStyles library and put the code inside of the sx={{ code styles }}. It's working fine on development and production |
@devrzztech see #30410 |
Hi @mnajdova I am experiencing the same issue. I followed the repo provided by MUI (https://github.com/mui/material-ui/tree/HEAD/examples/nextjs-with-typescript). The theme is applied in local dev but not when I deploy to production. (https://btdtech.io/) As you can see from the website, when you first visit it there is no styling applied. If you use the link to navigate to the ABOUT page then you will see it styled. However if you refresh the ABOUT page, the styling disappears again. This is the link to the repository for your perusal https://github.com/btdtech/company-website. Look forward to your reply! Bac |
Hi everyone, I have been digging and it seems that Emotion cache's style component has to style. Do we know why this is? I really would like to get to the bottom of this, otherwise I might have to find another CSS solution. Cheers, Bac |
Hi everyone, Just want to let you know that @siriwatknp found the solution for it. |
Duplicates
Latest version
Current behavior 😯
When using @mui/styles (Styles legacy) I seem to be getting a issue when deploying the application where a lot of the styles are loaded after the dom has reandered. Even though I use the ServerStyleSheets in my _documents.tsx, and create and use the theme in _app.tsx.
I do not understand why the style is not applied at the first time, on the first load.
Expected behavior 🤔
What should is that when rendering the page the first time all the style changes should already be there. but takes a small bit of time before it does.
https://imgur.com/a/ZujFrXd
Steps to reproduce 🕹
Steps:
Context 🔦
What I'm trying to accomplish is for my production build to look like my local development on initial load.
I think the issue lays in either the _documents.tsx or _app.tsx.
I have attached a link to the 2 images for how it looks in local development and production.
https://imgur.com/a/ZujFrXd
Your environment 🌎
System:
OS: Windows 10 10.0.19043
Binaries:
Node: 14.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Version 95.0.4638.69 (Official Build) (64-bit)
Edge: Spartan (44.19041.1266.0), Chromium (95.0.1020.44)
npmPackages:
@emotion/react: ^11.5.0 => 11.5.0
@emotion/styled: ^11.3.0 => 11.3.0
@mui/core: 5.0.0-alpha.53
@mui/lab: ^5.0.0-alpha.53 => 5.0.0-alpha.53
@mui/material: ^5.0.6 => 5.0.6
@mui/private-theming: 5.0.1
@mui/styled-engine: 5.0.2
@mui/styles: ^5.0.2 => 5.0.2
@mui/system: 5.0.6
@mui/types: 7.0.0
@mui/utils: 5.0.1
@types/react: ^17.0.34 => 17.0.34
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
typescript: ^4.3.5 => 4.3.5
The text was updated successfully, but these errors were encountered: