"use client"; import { useEffect, useState } from "react"; export const useSize = () => { const [windowSize, setWindowSize] = useState({ width: document?.body?.offsetWidth, height: document?.body?.scrollHeight, }); useEffect(() => { const windowSizeHandler = () => { setWindowSize({ width: document?.body?.offsetWidth, height: document?.body?.scrollHeight, }); }; window.addEventListener("resize", windowSizeHandler); return () => { window.removeEventListener("resize", windowSizeHandler); }; }, []); return { ...windowSize, getWindowSize: () => { return { width: document?.body?.offsetWidth, height: document?.body?.scrollHeight, }; }, }; };