question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSR Styling issue

See original GitHub issue

Hi, 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)

no-styles

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:closed
  • Created 2 years ago
  • Comments:40 (22 by maintainers)

github_iconTop GitHub Comments

4reactions
rtivitalcommented, Jul 16, 2021

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

3reactions
rtivitalcommented, May 8, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found