akashuba / react-timeline-animation

react-timeline-animation component
39 stars 7 forks source link

`window is not defined` error when trying to build with Next.js #1

Closed timendez closed 1 year ago

timendez commented 2 years ago
> Build error occurred
ReferenceError: window is not defined
    at Object.<anonymous> (node_modules\react-timeline-animation\dist\index.js:48:24)

From a fresh install, if I try to build I get that compile error

timendez commented 2 years ago

I had to wrap window in:

if (typeof window !== "undefined") {
  var halfScreenHeight = window.innerHeight / 2;
}
akashuba commented 2 years ago

Thanks, I will work on it. Be free to propose your solution on PR.

UPD: аdd type guards for "window" but keep it open until trying on Next.js.

jaycoolslm commented 2 years ago

Hi, I know I am a bit late! But, I've fixed this issue by importing the module dynamically using dynamic from "next/dynamic"

image