-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
[styled-engine] do not reuse the emotion cache across SSR requests #46276
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
Conversation
I created a reproduction here: robbtraister/mui-ssr-repro#1 When javascript is disabled in your browser, only the first request will be styled correctly. Subsequent requests will not have styles applied properly via SSR. After applying the patch in the pull-request linked above, the styles will be applied correctly on all requests. |
Netlify deploy previewhttps://deploy-preview-46276--material-ui.netlify.app/ Bundle size report@mui/material parsed: 🔺+27B(+0.01%) gzip: 🔺+2B(0.00%) Show details for 100 more bundles (86 more not shown)@mui/lab/AdapterDateFns parsed: 0B(0.00%) gzip: 0B(0.00%) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
When performing SSR, subsequent requests cannot reuse the same emotion cache, as it will think the style nodes have already been injected. This gates the cache reuse to only happening in a DOM environment (browser or jest).