-
-
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
SSR, makeStyles, overrides not same on each page reload #28994
Comments
same problem :( |
You haven't configured JSS for SSR. Is it intentional that you are using both emotion and JSS? If yes, take a look at the v4 examples/ssr for more info on how to configure it. |
@mnajdova, i got example from Plain server-side Update, okay, looks like so changes,
@mnajdova, can u approve it? and add to documentation PS, im only one confused what we needs to use both styles, ServerStyleSheets & emotionCss, it will not have conflicts? |
I would just change the order of these two lines: function renderFullPage(html, css, emotionCss) {
return `
<!DOCTYPE html>
<html lang="en">
<head>
<title>My page</title>
- <style>${css}</style>
- ${emotionCss}
+ ${emotionCss}
+ <style>${css}</style> So that the styles coming from jss (makeStyles, withStyles) would override those from emotion (the default styles for the components in v5).
@borm in v5 we are using emotion as a default styling engine. We think it's overhead to use JSS for styles overrides, as you would have to bundle two styling packages. This is why we don't document this. We have a section in the migration guide about how you can migrate from JSS - https://mui.com/guides/migration-v4/#migrate-from-jss There are two options: using the built in prop |
hm, is strange but it also works good without emotionCss, if i have removed - function renderFullPage(html, css, emotionCss) {
+ function renderFullPage(html, css) {
return `
<!DOCTYPE html>
<html lang="en">
<head>
<title>My page</title>
<style>${css}</style>
- ${emotionCss}
....
}
import { ServerStyleSheets } from '@mui/styles';
const sheets = new ServerStyleSheets();
const html = ReactDOMServer.renderToString(
sheets.collect(
- <CacheProvider value={cache}>
<ThemeProvider theme={theme}>
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
<CssBaseline />
<App />
</ThemeProvider>
- </CacheProvider>
)
);
// Send the rendered page back to the client.
- res.send(renderFullPage(html, sheets.toString(), emotionCss));
+ res.send(renderFullPage(html, sheets.toString())); PS, yes, i would like to continue working with jss as well, my vision is styled components was bad idea, and really not clear for understanding how it currently works in material core system, jss was pretty clear |
Lots of the reasoning is already covered in #22342 |
Current Behavior 😯
Expected Behavior 🤔
as i remember in v4 that issues was possible to fix by doing createGenerateClassName as a function
Steps to Reproduce 🕹
https://codesandbox.io/s/interesting-torvalds-j3lk8?file=/App.js
Steps:
:/sandbox$ webpack -w
if webpack will not start on dev mode authomatically,The text was updated successfully, but these errors were encountered: