leaffm / react-infinite-carousel

React simple infinite carousel with lazy loading and responsive support
MIT License
116 stars 19 forks source link

Server side rendering error #12

Open oyeanuj opened 5 years ago

oyeanuj commented 5 years ago

HI @gl0gl0, thank you for open sourcing this! I'm seeing the following error:

ReferenceError: window is not defined
    at /project-okay/node_modules/react-leaf-carousel/lib/react-infinite-carusel.min.js:6:14225

It seems that there needs to be a check for window before using it, which will then make it work on the server?

gl0gl0 commented 5 years ago

Sorry for the very late reply, I am working on the issue. But in order to use the lib, you can use this workaround which is the one I'm using at the moment, and works ok.

let InfiniteCarousel = null;
.......
componentDidMount() {
    InfiniteCarousel = require("react-leaf-carousel").default;`
}