import { useEffect, useRef, useState } from "react";
const useSize = (ref) => {
	const ticking = useRef(false);
	const [size, setSize] = useState();
	useEffect(() => {
		const resizeObserver = new ResizeObserver((entries) => {
			if (!ticking.current) window.requestAnimationFrame(() => {
				setSize(entries[0].target.getBoundingClientRect());
				ticking.current = false;
			});
			ticking.current = true;
		});
		if (ref?.current) resizeObserver.observe(ref?.current);
		return () => {
			if (ref?.current) resizeObserver.unobserve(ref.current);
			else resizeObserver.disconnect();
		};
	}, [ref?.current]);
	return size;
};
export { useSize as t };

//# sourceMappingURL=useSize.js.map