import { useState, useEffect } from "react";
import ResizeObserver from "resize-observer-polyfill";
const useResizeObserver = ref => {
  const [dimensions, setDimensions] = useState();
  useEffect(() => {
    const observeTarget = ref == null ? void 0 : ref.current;
    const resizeObserver = new ResizeObserver(entries => {
      entries.forEach(entry => {
        setDimensions(entry.contentRect);
      });
    });
    observeTarget && resizeObserver.observe(observeTarget);
    return () => {
      observeTarget && resizeObserver.unobserve(observeTarget);
    };
  }, [ref]);
  return dimensions;
};
export default useResizeObserver;
//# sourceMappingURL=useResizeObserver.js.map