react-infinite-carousel icon indicating copy to clipboard operation
react-infinite-carousel copied to clipboard

Server side rendering error

Open oyeanuj opened this issue 7 years ago • 1 comments

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?

oyeanuj avatar Oct 21 '18 22:10 oyeanuj

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;`
}

gl0gl0 avatar Dec 27 '18 16:12 gl0gl0