OriAmir / React-Responsive-Gallery

Simple and responsive gallery for react
45 stars 5 forks source link

Getting "Window is not defined" error on NextJS. Presumably there's no SSR support #9

Closed davidgoldcode closed 3 years ago

OriAmir commented 3 years ago

hi @davidgoldcode You right, currently the library don't support SSR

If you want you could open an MR and I will love to support that.

joebImagine commented 3 years ago

I ran into this same problem in NextJs. At least for now you will need to import this component like so:

const ResponsiveGallery = dynamic( () => import('react-responsive-gallery'), { ssr: false } );

from the docs: https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr

OriAmir commented 3 years ago

thanks @joebImagine ! @davidgoldcode I close this issue since we have a solution , if you have any other issues please open another issue,tnx.

PaulHaze commented 3 years ago

I ran into this same problem in NextJs. At least for now you will need to import this component like so:

const ResponsiveGallery = dynamic( () => import('react-responsive-gallery'), { ssr: false } );

from the docs: https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr

Ran into this exact same issue and this solved it. Thanks :)