import { useEffect } from 'react';
import { useEffectEvent } from './useEffectEvent.mjs';

function useResizeObserver(ref, callback) {
  const handleCallback = useEffectEvent(callback);
  useEffect(() => {
    if (ref.current != null) {
      const resizeObserver = new ResizeObserver(([entry]) => {
        handleCallback(entry);
      });
      resizeObserver.observe(ref.current, {
        box: 'border-box'
      });
      return () => {
        resizeObserver.disconnect();
      };
    }
    return () => {};
  }, [handleCallback, ref]);
}

export { useResizeObserver };
//# sourceMappingURL=useResizeObserver.mjs.map
