Responsive: SSR is broken
See original GitHub issueStack: Latest versions of Next.js, React, Semanic UI React.
Issue:
When I attempt to render the the example layout from here using Next.js, I get a warning that says Expected server HTML to contain a matching <div> in [<div>.
]
I believe it’s related to this issue https://github.com/Semantic-Org/Semantic-UI-React/issues/3110 which has something to do with the server not getting the browser size.
However, none of the solutions in that link worked for me. One requirement I have is that SSR cannot be turned off.
Here’s the code I’m using: https://github.com/jlei523/semantic-ui-next
Minor note: I believe https://react.semantic-ui.com/layouts/homepage/ is also affected by this issue. Go to the URL and then refresh the page and you should see the styles get messed up. If you shrink the browser window and then shrink it back, it displays the elements correctly again.
Has anyone solved this problem already without turning SSR off? Also, does anyone have an example of how to do display mobile specific elements using SUIR without turning off SSR?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:8 (5 by maintainers)
Solution 1: use
react-no-ssr
It’s simple, will omit all warnings.
HalfSolution 2: use
getWidth()
propStill will cause a warning on mobile devices 🐗
Solution 3: use
mobile-detect
The best solution that I know, everything works like a charm 👍
Live example on Codesandbox: https://codesandbox.io/s/ly3zpw7yzm
https://github.com/Semantic-Org/Semantic-UI-React/issues/4002#issuecomment-665000116
Responsive
will be deprecated and removed. I will provide an upgrade guide.