Server-side rendering: "window is not defined" error
See original GitHub issueThis 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:
- Created 4 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
Ah ok. You can make an extension of the class and put a dummy/null for window there for the time being.
That fixes it. But webpack injects
window
object in the build since the target is notnode
. I will send a pull request with what fixed it for me.