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 support on v5.0.0

See original GitHub issue

Using react-image-lightbox@5.0.0 on non-browser env(e.g. SSR) throws window is not defined error:

ReferenceError: window is not defined
    at Object.<anonymous> (/Users/nnishimura/works/git/my-repo/node_modules/react-image-lightbox/dist/main.js:3:3)

https://cdn.jsdelivr.net/npm/react-image-lightbox@5.0.0/dist/main.js

This is due to webpack issue, https://github.com/webpack/webpack/issues/6522

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
mmarkelovcommented, Jul 25, 2018

If you want use the latest version with SSR you can do something like this:

...
typeof window !== 'undefined' && <Lightbox/>
...
3reactions
nnishimuracommented, Jun 12, 2018

@Arrvin this issue only happens when you are using the latest version of react-image-lightbox (v5.0.0). So if you are on SSR app, you need to use v4.6.0 or below for now. Or you can wait for the next version which will have the fix 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSR (additional components)
next-i18next@v5.0.0 supports Next.js v9.5 in Serverless mode (as of July 2020). If your goal is to use earlier versions of Next.js with Serverless, ......
Read more >
Server-side rendering broken after upgrading to MUI 5 ...
I migrated my server-side rendering (SSR) working app to version 5 of MUI. ... run codemod (v5.0.0/preset-safe and link-underline-hover) ...
Read more >
Migrating to v5: getting started - Material UI - MUI
Additionally, v5 is the only version that fully supports React 18, ... update your packages to at least v4.11.2 for Material UI and...
Read more >
Can't create UMD build which can be required by Node
Node v8.9.4, webpack v4.0.0-beta.2 ... SSR support on v5.0.0 frontend-collective/react-image-lightbox#118.
Read more >
Simple Server Side Rendering, Routing, and Page ...
... my machine reverted to using Node v5.0.0. Which doesn't support various declarations found in the Nuxt/Starter codebase.
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