use temporary window
const [cwindow, setcwindow] = useState<any>(typeof window == 'undefined' ? {} : window);