avoid using window for SSR
See original GitHub issueWhen using this lib with next.js I get the following error:
/Users/bjoern/projects/compendium2/node_modules/react-tooltip/dist/index.js:1072
[1] if (typeof window.CustomEvent === "function") {
[1] ^
[1]
[1] ReferenceError: window is not defined
[1] at dispatchGlobalEvent (/Users/bjoern/projects/compendium2/node_modules/react-tooltip/dist/index.js:1072:3)
[1] at Function.target.rebuild (/Users/bjoern/projects/compendium2/node_modules/react-tooltip/dist/index.js:1102:5)
[1] at Timeout._onTimeout (/Users/bjoern/projects/compendium2/frontend/.next/server/static/development/pages/compendium/[slug].js:6594:60)
[1] at listOnTimeout (internal/timers.js:531:17)
[1] at processTimers (internal/timers.js:475:7)
error Command failed with exit code 1.
The problem exists, because on the server side window is undefined
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Using window in React SSR: The Complete Guide
Using window in React SSR: The Complete Guide What “window is not defined” and “expected server html to contain div” really mean.
Read more >React JS Server side issue - window not found - Stack Overflow
Your window && and if (window) checks with are failing because in JavaScript not declared and 'undefined' are different things.
Read more >Better handling for window object in SSR environment - GitHub
Better handling for window and document object in SSR environment. This library doesn't implement the DOM (like JSDOM), it just patches (or creates...
Read more >ssr-window - npm
Start using ssr-window in your project by running `npm i ssr-window`. There are 168 other projects in the npm registry using ssr-window.
Read more >Window is undefined during SSR - RichHewlett.com
If when server side rendering a React application (other JS frameworks are available) that makes use of the global window object during the ......
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
I’m not having problems with
window
but instead, with thedocument
refer to #618Yeah, I saw before that it could be implemented as a util. I would check it.