'use strict';

var React = require('react');
var useEffectEvent = require('./useEffectEvent.js');

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

exports.useResizeObserver = useResizeObserver;
//# sourceMappingURL=useResizeObserver.js.map
