-
Notifications
You must be signed in to change notification settings - Fork 23
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
Incorrect styling after switching to client side #61
Comments
Hey @morawskiOZ, I am running into the same issue - but I have to click on an internal link to leave the page and return and the correct CSS shows up. I am using the material UI starter and I just started to rewrite all my components with styled-components. So the s-c library is present and configured. But I still have some JSS present. I am not sure if this is my issue. Are you using styled-components? And did you make any other changes to the official starter? And are you on Material-UI 4 or already on the 5 preview? |
I have this issue on my open source website also. Still dont know how to fix it. |
The best approach here is to work with a dichotomy, remove as much code as possible to keep reproducing the issue. |
I found my problem - I believe the issue lies in I am using |
Hey @mpolinowski Sorry for the late response. I see you fixed your problem somewhat but I am still gonna respond. I am running pure MUI v5 without Styled Components. The initial setup was pretty minimal almost official starter level. I tested a similar setup with Next and custom CRA and didn't have any problems so it must be Gatsby's hydration issue. |
Ok thanks! Yes, it turned out that my issue had nothing to do with mui v4 vs v5 or
|
Run into this same issue with a POC our company is testing. Is this really a Gatsby hydration issue? It sounds from previous comments like it has nothing to do with mui or styled-components. Is this an accurate statement? |
For me, using the layout plugin in combination with the HOC withStyles was the issue. Everything works as expected now after removing the HOC's from my child components. Are you using deeply nested components? I had the same issue in the past with a page that was nested 4 layers deep - layout / page / child / child-of-the-child. The component was breaking on first pageload and when you reloaded the page. I re-wrote it so that I could remove the lowest layer and the issue went away. I am not sure if that actually was the solution. But I have been taking care that I do not go deeper than the 3rd layer below the layout and the issue never returned. It might have also been related to the HOC issue above, though. |
I've also just started experiencing this issue. I'll keep my progress updated while following the advice in this thread and fixing it, but though I'd post just in case. We've been building a site for a few months now and it's only happening on the The classes created by
|
It turns out that for me the problem started when I enabled |
Hey @mpolinowski,
Thx for yours and everyone's input. Would you mind expanding on this statement? Although removing
I have it set up so that if you link internally to any page starting with However, if linked directly to a nested account page, such as It's worth noting that in this situation, landing on What I'm confused about is that in all cases, it's only the
The footer:
There is something special about the Thoughts? |
Problem:
![server](https://user-images.githubusercontent.com/41105888/96990634-a7ea7380-1527-11eb-8f84-74ef2e5e8d6b.png)
![client](https://user-images.githubusercontent.com/41105888/96992077-a9b53680-1529-11eb-91c1-e95c3a93b4f6.png)
After switching from SSR to client-side and dom hydration some of the jss styles are off and the whole layout is out of whack. Screenshots with an affected component for both server and client renders:
What you see on the screenshots is class name collision, somehow after hydration class name was generated again with a lower index which was already taken. I tried adding seed to the classnames generator, the collision was gone but the class was simply empty after hydration.
What I've already found:
I traced the problem to this gatsby issue gatsbyjs/gatsby#17676. The solution with replacing hydration function from hydrate to render. It works, but it is a performance hit and with React 17 it is said it soon will be deprecated
Solution:
Fixable ?
Any tips for a better solution? I am really surprised nobody else has had this problem. Any chance we might fix this within the plugin?
The text was updated successfully, but these errors were encountered: