From 97d45ec60927f1e3c32de40ba194b7e34809b219 Mon Sep 17 00:00:00 2001 From: salhotra Date: Mon, 22 Jul 2024 17:55:18 +0530 Subject: [PATCH] Fix window reference error --- src/app/components/About.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/components/About.tsx b/src/app/components/About.tsx index 3e624c5..144966b 100644 --- a/src/app/components/About.tsx +++ b/src/app/components/About.tsx @@ -36,11 +36,18 @@ const useContainerSize = (ref: React.RefObject) => { const useWindowSize = () => { const [windowSize, setWindowSize] = useState({ - width: window.innerWidth, - height: window.innerHeight, + width: 0, + height: 0, }); useEffect(() => { + // Initial window size. This is done here instead of in the useState + // declaration because the window object is not available on the server. + setWindowSize({ + width: window.innerWidth, + height: window.innerHeight, + }); + const handleResize = () => { setWindowSize({ width: window.innerWidth,