Add fallback to `window` in order to support SSR
See original GitHub issueCurrently, OperationalUI
uses a lot of properties on window.
to handle resize, etc. The problem here is that when we try to render Operational UIs server-side, there is no window
object and so the entire app breaks.
Solving this is a one-liner and would just add a fallback to an empty object to the component.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Server Side Rendering fallback for old browsers
Our initial idea was to create an specific action to be used when Proxy is not supported, similar to afterCSR() , where packages...
Read more >How to implement server-side rendering (SSR) in your React ...
We install express and some tool to make i18next working on the server ... Suspense is not supported in SSR currently, and on...
Read more >Streaming server-side rendering (SSR) - Shopify Developers
This guide describes how streaming server-side rendering (SSR) works in a Hydrogen ... to add a layout fallback to improve cumulative layout shift...
Read more >Window is not defined in Next.js React app - Stack Overflow
In Next.js, componentDidMount() is executed only on the client where window and other browser specific APIs will be available. From the Next.js wiki:....
Read more >Suspense for Data Fetching (Experimental) - React
It lets data fetching libraries deeply integrate with React. If a data fetching library implements Suspense support, using it from React components feels...
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
Awesome, I’ll start working on it. And create a PR.
New take on things 😁 😅 Forget what I said before 😛 lol
I created a SSR app, just to be sure of the entire process. The window & document object is available in SSR. With a slight catch. If you go through the rendering process. Unless or until the
render()
method isn’t called. The ‘document’ object isn’t available because it has not been rendered. So my advice for this would be to usedocument.body
instead ofwindow
because IE doesn’t work withwindow
in some cases. And both Chrome, Firefox can handledocument.body
and it is supported inIE
as well.My 2 cents will be to use the life cycle in the entire UI library accordingly. Call 'document.body.` after the UI has rendered and not before that. Otherwise it will not work. This is the same approach that Material UI uses as well.
Your thoughts?