-
-
Notifications
You must be signed in to change notification settings - Fork 866
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
Hydration of Styles Not Rendering Properly #771
Comments
Hahahaha I had the same problem with Material UI in Razzle 😢 |
@CharlyJazz That's very (en|dis)couraging. Haha did you try moving away from their |
You'd think after long tedious hours of researching and debugging it would be a little more gratifying, but the fix is basically using after.js, react-jss, generating your own static async getInitialProps({ assets, data, renderPage }) {
const generateClassName = createGenerateClassName()
const jss = create(jssPreset())
const page = await renderPage(App => props => (
<JssProvider jss={jss} generateClassName={generateClassName}>
<MuiThemeProvider sheetsManager={new Map()}>
<App {...props} />
</MuiThemeProvider>
</JssProvider>
))
return { assets, data, ...page }
} May you all avoid the pain. :P |
@jaredpalmer @jylinman Is it not possible to create an example of this for the razzle documentation? |
To anyone else experiencing this issue I can highly recommend following the official Material-UI SSR docs: https://material-ui.com/guides/server-rendering/ |
Loving razzle, such a great tool.
I am having an issue where I setup Material UI and everything is working fantastically except for one thing: When visiting a sub page and refreshing the page gives me a page with only minimal styles. It's actually a fascinating bug because depending on what page was open from the last
yarn start
it would only render that page properly if refreshed, but if I navigate and refresh it will not work (even on the root path).yarn start
http://localhost:3000/blog-posts
for exampleyarn start
I tried
yarn build && yarn start:prod
and the system runs, but only with minimal styles. However, if I find a link and click it then the whole application looks beautiful again.I am assuming it's an issue with hydrate or maybe some combination of that and
@material-ui/core/styles/withStyles
. Are any of you encountering this issue?The classes are different (rendered html) on subsequent page load which means it's probably related to the initial loading of isomorphic styles / classes which I am aware relates to the following discussions:
However, as my situation shows above, it seems to be working some of the time which makes me think its closer than those discussions are making it appear. Thoughts?
The text was updated successfully, but these errors were encountered: