closeio / react-custom-scroller

Super simple React component for creating a custom scrollbar cross-browser and cross-devices.
MIT License
36 stars 8 forks source link

react-custom-scroller Not Working With Next.js #17

Closed ApplePieGiraffe closed 3 years ago

ApplePieGiraffe commented 3 years ago

I'm trying to use react-custom-scroller with Next.js, but when I import react-custom-scroller into one of my files and try to render my page, I get the error, "ReferenceError: document is not defined."

Is this because react-custom-scroller is trying to access the document on the server or something?

IDK, but what can I do to fix this?

capatillo commented 3 years ago

This is because Next.js do SSR (server-side-rendering). Just wrap your import like this:

import dynamic from 'next/dynamic'; const CustomScroller = dynamic( () => import('react-custom-scroller'), { ssr: false });

ApplePieGiraffe commented 3 years ago

Ooh, okay, thank you.