You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
In the root gatsby-ssr.js and gatsby-browser.js, I had wrapped my element with @mui's <ThemeProvider>. This worked OK for gatsby-ssr.js - styles came out where expected.
However, on the initial client re-render, the emotion <style> tags would be rearranged and moved to be the first child (from the last). I assume it is due to getting a different theme. I could not get this to work by putting the <ThemeProvider> into its own plugin.
Using
@emotion/styles 11.6
@emotion/react 11.6
gatsby 3.14.1
gatsby-plugin-material-ui v.4.1.0
The text was updated successfully, but these errors were encountered:
nagiek
changed the title
gatsby-plugin-material-ui rearranges style order during hydration if <ThemeProvider> is used.
[v4] gatsby-plugin-material-ui rearranges style order during hydration if <ThemeProvider> is used.
Nov 20, 2021
Problem
In the root
gatsby-ssr.js
andgatsby-browser.js
, I had wrapped my element with @mui's<ThemeProvider>
. This worked OK for gatsby-ssr.js - styles came out where expected.However, on the initial client re-render, the emotion
<style>
tags would be rearranged and moved to be the first child (from the last). I assume it is due to getting a different theme. I could not get this to work by putting the<ThemeProvider>
into its own plugin.You can see the official implementation here:
https://mui.com/guides/server-rendering/#handling-the-request
This took a while to debug, hope it helps someone.
Old - within root gatsby-ssr.js:
New - within new plugin (fork of this plugin):
Using
@emotion/styles 11.6
@emotion/react 11.6
gatsby 3.14.1
gatsby-plugin-material-ui v.4.1.0
The text was updated successfully, but these errors were encountered: