2

I have built 2 projects in React.js, one is using material ui 4 and another one is using mui5. Both the websites are working fine and styling is also perfect. I have noticed that in the project which is built using material ui 4, I can see style tags are loading whereas in the project which is built using mui 5 style tag with CSS is not there. PFB the screenshot.

I am using pre-render.io for prerendering website, due to the above behavior website built using material ui 5 is showing proper styling to the bot whereas, in the case of the mui5 website, no CSS is loading for the bot.

MUI 5 project:

enter image description here

Material UI 4 project:

enter image description here

I have utilized both the material version as per the doc on their website. The only difference is mui5 project is built with CRA and the material ui 4 project is built with a custom webpack.

How can I load mui 5 styling in case of prerendering using prerender.io

1 Answer 1

1

You can cache it, mui documentation recommends that.

https://mui.com/material-ui/integrations/interoperability/#emotion

const emotionCache = createCache({
    key: 'css',
    container: document.head, // pointing to <iframe>.document in this case, ymmv
    prepend: true, // ymmv
    speedy: false // <--- key setting
  })

<CacheProvider value={emotionCache}>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, it works

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.