import { useEffect, useRef, useState } from "react";
const useResizeObserver = (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]);
	return size;
};
export { useResizeObserver as t };

//# sourceMappingURL=useResizeObserver.js.map