import { useCallback, useEffect, useState } from "react";

const useSize = () => {
    const [width, setWidth] = useState(0),
        [height, setHeight] = useState(0),
        setSizes = useCallback(() => {
            setWidth(window.innerWidth)
            setHeight(window.innerHeight)
        }, [setWidth, setHeight])
    useEffect(() => {
        window.addEventListener("resize", setSizes)
        setSizes()
    }, [setSizes])
    return [width, height]
}

export default useSize
