-
-
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
[examples] MUI is missing style when navigating back from error page in remix example #30436
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I encountered the same bug using Next.js, so it doesn't seem to be limited to Remix. |
Same bug here. I was about to post the exact same repro. |
On the client, styleData is Here is a workaround: pass data from server to client using a let styleData = useContext(StylesContext);
if (!styleData && typeof window !== "undefined") {
styleData = (window as any)?.__STYLE_DATA__ as StyleContextData[] | null;
} And {styleData && (
<script dangerouslySetInnerHTML={{ __html: `window.__STYLE_DATA__ = ${JSON.stringify(styleData)}` }} />
)} This is a link to a working sample using this technique:
|
I spend some time digging into this subject, and here is my understanding and how I finally solved it. ContextEmotion, dynamically injects
SolutionRe-inject tags and re-link to current
|
@lvauvillier It actually works 🤯 Good job! |
@lvauvillier It helps a lot, thanks! |
Reopening for inclusion in the Remix example. |
@lvauvillier I was on vacation, I've just seen your comment. Let me test it and verify that it works, and I will update the Remix example. |
@lvauvillier I've created #30592 based on your codesandbox. The only problem I could notice is the flickering when going from 404 to a valid page. I think it's coming from the GlobalStyles. Note that I've updated in the meantime the example project to not require double rendering (see remix-run/remix#1325, seems like the example don't he remix docs will be updated too). I will look into the flickering next, it's important for us to fix it before we release this. BTW I could notice the flickering on your sandbox too, so I don't think it's related to the changes with the double rendering. |
@lvauvillier never mind, I fixed it by replacing the |
@mnajdova yeah! I also iterate around |
@lvauvillier right, we can use the |
It's been not so easy to figure out, but solution and example helped a lot. I think now my app works even better then before:) |
Duplicates
Latest version
Current behavior 😯
MUI is missing style when back from error page in remix.
Expected behavior 🤔
Right style show
Steps to reproduce 🕹
Steps:
sandbox: https://codesandbox.io/s/awesome-voice-n5o0j
Context 🔦
It seems that styleData not reset after back from error page, this action happens only in browser not having a request to server to rerender html.
Your environment 🌎
System:
OS: Windows 10 10.0.22000
Binaries:
Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.15 - C:\Program Files\nodejs\yarn.CMD
npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.22000.120.0), Chromium (96.0.1054.62)
npmPackages:
@emotion/react: latest => 11.7.1
@emotion/styled: latest => 11.6.0
@mui/base: 5.0.0-alpha.62
@mui/material: latest => 5.2.6
@mui/private-theming: 5.2.3
@mui/styled-engine: 5.2.6
@mui/system: 5.2.6
@mui/types: 7.1.0
@mui/utils: 5.2.3
@types/react: latest => 17.0.38
react: latest => 17.0.2
react-dom: latest => 17.0.2
typescript: latest => 4.5.4
The text was updated successfully, but these errors were encountered: