import React from "react";
const useComponentDimension = (myRef) => {
    const getDimensions = () => ({
        width: myRef.current.offsetWidth,
        height: myRef.current.offsetHeight,
    });
    const [dimensions, setDimensions] = React.useState({ width: 0, height: 0 });
    React.useEffect(() => {
        const handleResize = () => {
            setDimensions(getDimensions());
        };
        if (myRef.current) {
            setDimensions(getDimensions());
        }
        window.addEventListener("resize", handleResize);
        return () => {
            window.removeEventListener("resize", handleResize);
        };
    }, [myRef]);
    return dimensions;
};
export default useComponentDimension;
//# sourceMappingURL=useComponentDimension.js.map