I use useState to get the window height but it gives a runtime error saying that window is not defined. Do you know why
Here's the code:
let [winHeight,setWinHeight] = useState(window.innerHeight)
useEffect(() => { const list = [] for (var i=0;i<datas.length;i++){ const t = datas[i].title const res = handleResize(i + 2) list.push(<li ref={resl[i + 1]} style={{top: "20px",left: res +"px"}}><Anchor href={datas[i].link || `/${t.replace(/ /g, "_")}`}><a onClick={() => closeNav()} onMouseOver={() => setHovering(i)}>{t}</a></Anchor></li>) } setWinHeight(window.innerHeight) setLinks(list) }, [winHeight])