Closed StefanoSega closed 5 years ago
Never mind I didn't implement properly SSR
@StefanoSega i've seeing this with react-static
and Material-UI too. What was your issue with SSR?
@digitalkaoz I just didn't implement MUI SSR at all, once I wrapped the initial component with JssProvider and MuiThemeProvider I was able to get the MUI css from the backend:
const sheetsRegistry = new SheetsRegistry();
const sheetsManager = new Map();
const theme = createMuiTheme();
const generateClassName = createGenerateClassName();
const reactHtml = ReactDOMServer.renderToString(
<JssProvider registry={sheetsRegistry} generateClassName={generateClassName}>
<MuiThemeProvider theme={theme} sheetsManager={sheetsManager}>
<Provider {...stores}>
<RouterContext
{...renderProps}
createElement={(Component: any, props: any) => (
<Component
{...props}
/>
)}
/>
</Provider>
</MuiThemeProvider>
</JssProvider>
);
const muiSsrStylesCss = new CleanCSS().minify(sheetsRegistry.toString()).styles;
const reactCss = `<style id="jss-server-side">${muiSsrStylesCss}</style>`;
Expected Behavior 🤔
Using one of the icons and applying to it an inline styling from the
style
prop it should apply correctly the style and all the inherited styles to the icon even when server-side rendered.Current Behavior 😯
When reloading the page the icon doesn't take the inline styles and the inherited styles for the first second, then it looks good.
Steps to Reproduce 🕹
Link:
the icon during the first second of page loading it doesn't take the specified font size and so consequently appears way bigger; also it doesn't inherit the color from the parent.
Context 🔦
I've an app with fully working SSR; the HTML get rendered and styled perfectly from SSR except for the material-ui/icons.
Your Environment 🌎