react-date-countdown-timer
react-date-countdown-timer copied to clipboard
Server Error ReferenceError: window is not defined
Server Error ReferenceError: window is not defined error
Hello BryantIT, can you please check again? I've made some updates to the component, it should be fine now.
Just a heads up! This is still happening.
Ditto @mikemajara! This is still happening. Any luck with a fix?
Hey @cengizhanbasak this is still an issue
Still happening to me too, using nextJs
@cengizhanbasak same issue occur
Same issue just tried it now.
same here
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")}
/>
);
}
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`