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.

Server-side rendering: "window is not defined" error

See original GitHub issue

This library breaks SSR since it assumes that the window object is available in https://github.com/DominicTobias/react-image-crop/commit/9417719b766a9417afaf628f10fef8425f69e936#r33877568

Before using the window object, please be wary and check whether the window object is defined (typeof window === 'undefined').

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
DominicTobiascommented, Jun 10, 2019

Ah ok. You can make an extension of the class and put a dummy/null for window there for the time being.

0reactions
ArtBITcommented, Jun 10, 2019

That fixes it. But webpack injects window object in the build since the target is not node. I will send a pull request with what fixed it for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React JS Server side issue - window not found - Stack Overflow
BROWSER to my advantage because it will be defined as undefined if it is server side, and it will be true if the...
Read more >
Using window in React SSR: The Complete Guide
window is not defined on the server, so you can't use it during the render of a component being SSR'd. ... During a...
Read more >
How to solve Next.js window is not defined
An easy solution to resolve this issue is to rely on the useEffect , conveniently hooks aren't run when doing server-side rendering. Wrapping ......
Read more >
How to solve "window is not defined" errors in React and Next.js
A different solution is to load your Scroll component using dynamic imports and the srr: false option. This way your component won't even...
Read more >
How to Fix "window is not defined" in Next.js - Upmostly
This issue has to do with Server-Side Rendering in Next.js. Next.js will by default try to use SSR for your site.
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