SSR Styling issue
See original GitHub issueHi, I’m using Next.js (Blitz.js) and there’s an issue with the example provided in here. When I refresh the page in a particular route (/login for example) all the styles are removed (SSR rendering)
And it seems to be related to the useEffect
from the _app.js
mentioned in the guide
useEffect(() => {
const jssStyles = document.getElementById("mantine-ssr-styles")
if (jssStyles) {
jssStyles.parentElement.removeChild(jssStyles)
}
}, [])
If I remove that the styles are in place again when I refresh the route /login
but the theme light/dark
isn’t working, the elements don’t switch the theme properly.
In the main route localhost:3000
the issue is not reproducible, only in internal routes.
I’m using the latest mantine
version with react-jss
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:40 (22 by maintainers)
Top Results From Across the Web
styled-components are not working with Next.js SSR #3634
Hello, I've recently come to know about the babel-plugin-styled-components and added the following code snippet into .babelrc.
Read more >Advanced Usage - styled-components
This doesn't interfere with global styles, such as keyframes or createGlobalStyle and allows you to use styled-components with React DOM's various SSR APIs....
Read more >JavaScript-less Static SSR using Styled Components
The issue with this approach is that the HTML is rendered separately from the style tags, which means that the style tags need...
Read more >SSR with Next.js, styled-components and Material UI
Material-UI and styled-components perfectly work fine on all of the components. The goal of this article is to share how to use server-side...
Read more >Next.js Styled Components weird behaviour - Stack Overflow
So basically in order to use styled-components with server side rendering, ... I had to spend a lot of time to solve the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Alright, I’ve investigated the issue with blitz and found out it uses experimental Suspense API, which does not support server side rendering, once it’s out we will run some additional testing and fix an issue if this happens again, for now I’ll close these issues
I’ve managed to replicate SSR issue with mantine docs. If you refresh page with component which uses Portal (e.g. Modal) some styles will be corrupted – https://mantine.dev/core/drawer/ These two things must be connected