min30327 / luxy.js

Inertia scroll and parallax effect plugin in Vanilla.js
598 stars 86 forks source link

Importing issue in react js project #36

Open saadcrest opened 1 year ago

saadcrest commented 1 year ago

I cannot use your incredible smooth scrolling library due to errors while importing in react js project. Please guide me to implement this in my project. Screenshot 2023-02-27 172158

onukwilip commented 1 year ago

It simply says that the window object is not defined and it seems like you are using Next.Js not just React.Js in your project. In Next.Js projects we call the window object a little differently. Next.Js offeres server side rendering, which means that your site runs on the server before running on the client. There is no window object on the server (Node.Js). Therefore, try calling the window object from the useEffect Hook. Refer to this article for better explanation. https://articles.wesionary.team/window-object-in-nextjs-1e505349c6f5