diff --git a/src/v2/Utils/Hooks/useWindowSize.ts b/src/v2/Utils/Hooks/useWindowSize.ts index f7acc436a27..07a6a272f47 100644 --- a/src/v2/Utils/Hooks/useWindowSize.ts +++ b/src/v2/Utils/Hooks/useWindowSize.ts @@ -4,6 +4,10 @@ import { getViewportDimensions } from "v2/Utils/viewport" export const useWindowSize = () => { const [size, setSize] = useState({ width: 0, height: 0 }) + if (typeof window === "undefined") { + return size + } + useLayoutEffect(() => { function resize() { const { width, height } = getViewportDimensions() @@ -15,9 +19,5 @@ export const useWindowSize = () => { return () => window.removeEventListener("resize", resize) }, []) - if (typeof window === "undefined") { - return { width: 0, height: 0 } - } - return size }