dantrain / react-stonecutter

Animated grid layout component for React
http://dantrain.github.io/react-stonecutter
MIT License
1.21k stars 72 forks source link

window not defined error #7

Closed huntersinclairtiv closed 8 years ago

huntersinclairtiv commented 8 years ago

If I include this module in my react project I get window undefined error thrown related to enquire.js library.

phil3903 commented 8 years ago

+1

I started a new server-side rendering project and got the same issue.

/node_modules/enquire.js/dist/enquire.js:8 var matchMedia = window.matchMedia; ReferenceError: window is not defined

I don't know much about enquire.js, but it sounds kinda of obvious that it can't find a window on the server

dantrain commented 8 years ago

Hi guys,

I've tried to fix this by conditionally loading the dependency if window is available. Let me know if it helps!

phil3903 commented 8 years ago

Sadly, my issue still exists. Thanks for jumping on it this quick though!

dantrain commented 8 years ago

This is very annoying but I've tried again by changing the output from 'umd' to 'commonjs2', which I hope is fine for most people!

phil3903 commented 8 years ago

Definitely fixed. No more crash. Thanks!

dazorni commented 7 years ago

Currently i have the same problem. With v8 and server side rendering i can't load the component. We currently have to set the window property for some other plugins. So this is no option for us :( Is there another way to handle this properly?