-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
useTheme
doesn't reflect custom theme values when used with Remix SSR setup
#31233
Comments
Mui: v5.8.1 I think there is a problem with When I debug my code, Mui's
My expectation is that, it would supposed to go in this different
I have code like this, my component tried to grab the theme using
I have the following custom provider which, when dumping the incoming theme object, it has everything I defined, but not in the children.
In fact, even within my
Is this related? `npx @mui/envinfo`
|
This also happens with Next.js SSR. |
In our project (with SRR and custom Module Federation config), we were able to replicate this same issue. "@mui/material" totszwai message seems to be on the right direction from my POV. Let me know if you need more details to solve this 🙂. Thanks! EDIT: what we did in our case is to add "@mui/system" as a singleton to our webpack config. Because of our Module Federation, it seems 2 versions of this library were loaded and conflicting. Not sure if it's related to this issue, but mentioning it here in case it helps somebody. |
I am able to reproduce this using storybook 7. useTheme always returns the system theme (but styled() works correctly. |
After quite of bit of effort I was able to get past this and the related issue #32806. @W01fw00d My resolution was similar my resolution. |
Duplicates
Latest version
Current behavior 😯
Used Remix + MUI example as a base without any changes. I tried using the
useTheme
hook inCopyright
component so I can use custom theme values defined increateTheme
, but thetheme
object fromuseTheme
doesn't contain values defined in the custom theme object.Console logging the theme object from
useTheme
shows correct values on the server, but wrong values in the browser.The bug happens in any component but here's how I encountered it in
Copyright.ts
file:How
theme.ts
file looks:Expected behavior 🤔
Resulting theme object from
useTheme
should reflect any values defined in the custom theme object passed tocreateTheme
.Steps to reproduce 🕹
Steps:
Current behavior
section intoapp/src/Copyright.tsx
filenpm run dev
, open the browser and check the consoleContext 🔦
Remix + MUI example
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: