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.

Add fallback to `window` in order to support SSR

See original GitHub issue

Currently, 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:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
adeelibrcommented, Sep 22, 2018

Awesome, I’ll start working on it. And create a PR.

1reaction
adeelibrcommented, Sep 22, 2018

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 use

document.body.

document.body instead of window because IE doesn’t work with window in some cases. And both Chrome, Firefox can handle document.body and it is supported in IE 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?

Read more comments on GitHub >

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

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