telecta / react-mousetrap

HOC for Mousetrap
https://www.npmjs.com/package/react-mousetrap
MIT License
31 stars 7 forks source link

ReferenceError: window is not defined #1

Closed jamesdwilson closed 6 years ago

jamesdwilson commented 8 years ago

Window should not be referenced if it is being called in a server context.

ReferenceError: window is not defined at Object. (/home/james/projects/X/frontend/node_modules/react-mousetrap/node_modules/mousetrap/mousetrap.js:1021:5) at Module._compile (module.js:435:26) at Object.Module._extensions..js (module.js:442:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17) at require (module.js:385:17) at Object. (/home/james/projects/X/frontend/node_modules/react-mousetrap/lib/index.js:12:18) at Module._compile (module.js:435:26) at Object.Module._extensions..js (module.js:442:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Module.require (module.js:366:17) at require (module.js:385:17) at Object. (/home/james/projects/X/frontend/lib/prerender/app.js:9997:19) at __webpack_require__ (/home/james/projects/X/frontend/lib/prerender/app.js:21:30) TRACE: preRenderApp: 410ms16.01.1

tshinnic commented 8 years ago

Note the comments in source for React-HotKeys that might give a strategy to address the problem?

ccampbell commented 8 years ago

Mousetrap 1.6.0 should address this. It should no longer error when used in a server side environment

alvinsj commented 6 years ago

it's updated in 0.2.0