react-date-countdown-timer icon indicating copy to clipboard operation
react-date-countdown-timer copied to clipboard

Server Error ReferenceError: window is not defined

Open BryantIT opened this issue 4 years ago • 10 comments

Server Error ReferenceError: window is not defined error

BryantIT avatar Sep 21 '20 02:09 BryantIT

Hello BryantIT, can you please check again? I've made some updates to the component, it should be fine now.

cengizhanbasak avatar Oct 17 '20 13:10 cengizhanbasak

Just a heads up! This is still happening.

mikemajara avatar May 11 '21 07:05 mikemajara

Ditto @mikemajara! This is still happening. Any luck with a fix?

conradlin avatar Jun 29 '21 07:06 conradlin

Hey @cengizhanbasak this is still an issue

iHildy avatar Jan 20 '22 13:01 iHildy

Still happening to me too, using nextJs

romulorod avatar Apr 19 '22 17:04 romulorod

@cengizhanbasak same issue occur

Frankiz123 avatar Jun 03 '22 17:06 Frankiz123

Same issue just tried it now. image image

bestii avatar Jun 19 '22 20:06 bestii

same here

rondlite avatar Jul 21 '22 08:07 rondlite

You can use dynamic imports to get around this issue.

import dynamic from "next/dynamic";

const DateCountdown = dynamic(() => import("react-date-countdown-timer"), {
  ssr: false,
});

export default function Home() {
  return (
    <DateCountdown
      dateTo="January 01, 2023 00:00:00 GMT+03:00"
      callback={() => alert("Hello")}
    />
  );
}

fishactual avatar Aug 31 '22 21:08 fishactual

Using the previous answers , this is a component por Nextjs using typescript.

`import React from 'react' //@ts-ignore import dynamic from "next/dynamic"; // import DateCountdown from 'react-date-countdown-timer'; type Props = {} //@ts-ignore const DateCountdown = dynamic(() => import("react-date-countdown-timer"), { ssr: false, });

const TrialCountDown = (props: Props) => { if (typeof window !== "undefined") { // Client-side-only code return ( //@ts-ignore <DateCountdown dateTo='2022-10-20T12:51:04.961Z' callback={()=>{alert('hello')}} /> ) }

}

export default TrialCountDown`

yosle avatar Sep 20 '22 15:09 yosle