Replies: 1 comment 3 replies
-
For me HydrateFallBack is not working at all, using clientLoader in a non-ssr application. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone!
I'm working on a React Router 7 app, using MUI (with Emotion as the styling engine) pretty much exclusively for UI components and styles. I'm trying to get MUI/Emotion styling working between server-side and client-side renderings of the page, and running into a snag:
When rendering my Root Route, I'm using a
HydrateFallback
as the initial server rendering and while theclientLoader
is running. However, while the initial server-rendered version of the page has the expected MUI styling for the components I use (e.g. aProgressCircular
), it seems that as soon as theclientLoader
starts running, the styles (i.e. all the<style>
tags inserted by Emotion initially) disappear entirely, only to reappear after theclientLoader
finishes.Since I'm using
HydrateFallback
, my current interpretation of this is that the DOM rendered for theHydrateFallback
doesn't include the MUI/Emotion elements needed to render the<style>
tags immediately when the hydration starts. However, I have wrapped the contents ofHydrateFallback
with a<CacheProvider>
and<ThemeProvider>
, identical to the normal page content.Also, it's not clear to me why a new page is being rendered at all: by my reading of the React Router 7 docs, at least, it seems that the server-rendered version is theoretically what should be getting rendered up until the completion of the
clientLoader
-- am I misunderstanding that part?Here are some further details:
Versions/Libraries:
@mui/material
: 5.15.19@emotion/cache
: 11.14.0@emotion/react
: 11.14.0@emotion/server
: 11.11.0@emotion/styled
: 11.11.0entry.server.tsx: using the default
entry.client.tsx: does some setup of hosting- and analytics-related variables, then performs the hydration via:
React Router 7 config:
root.tsx
Any help with unraveling this conundrum would be much appreciated!
Beta Was this translation helpful? Give feedback.
All reactions