-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSR on Next.js doesn't work #32
Comments
Hi Michael, thank you for the detailed explanation of the issue. I'll give it a look, hopefully, this week. And thank you for your kind words and for the ⭐️, this means a lot to me 🥦 |
Workaround: import dynamic from 'next/dynamic
// Img Comparison Slider cannot be server-side rendered
const ImgComparisonSlider = dynamic(() => import("@img-comparison-slider/react").then((mod) => mod.ImgComparisonSlider), {
ssr: false
}) This work really well for the time being ^. There is a thread here about issues with other libraries too: asyncapi/asyncapi-react#177. Would be cool to make the lib SSR compatible. |
## [5.0.2](v5.0.1...v5.0.2) (2021-06-18) ### Bug Fixes * **react:** align class names between web and react commponents ([d9c7df5](d9c7df5)) * **react:** align tabindex between web and react components ([be8cfdc](be8cfdc)) * consider tabindex attribute ([ebc4a9a](ebc4a9a)) * reevaluate slider position on component's size change ([e03e798](e03e798)) * **react:** ssr ([e023ebe](e023ebe)), closes [#32](#32)
🎉 This issue has been resolved in version 5.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hi Michael, the issue has been resolved in The component could be used as described in the documentation https://github.com/sneas/img-comparison-slider/blob/master/bindings/react/README.md Cheers! |
Thank you for this great component 👍 . I can't wait to use it!
I tried to use it on my Next.js project and it complained about:
The reason is that node.js assumes you use common.js modules unless you have
type: 'modules'
in thepackage.json
. I quickly manually changed the code to use commonjs modules (require and module.exports). However, it still requireswindow.document
somewhere in the code.I'm not sure how other libraries do this, but it seems to work flawlessly with say
react-color
(https://github.com/casesandberg/react-color). It might be a good place to start to find out.If you have any quick work arounds that would be great too, I tried the one mentioned here: https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr, but since this lib uses named exports it didn't quite work.
The text was updated successfully, but these errors were encountered: