'use strict';

var useResizeObserver = require('use-resize-observer');
var warning = require('warning');
var componentUtilityFunctions = require('../utils/componentUtilityFunctions.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var useResizeObserver__default = /*#__PURE__*/_interopDefault(useResizeObserver);
var warning__default = /*#__PURE__*/_interopDefault(warning);

var useResize = function useResize(resizeRef) {
  if (!componentUtilityFunctions.browserSupports('ResizeObserver')) {
    warning__default.default(!("development" !== "production"), 'The current browser does not support ResizeObserver. You will need to include a ResizeObserver polyfill for this component to function properly.') ;
    return null;
  }

  /**
   * use-resize-observer currently crashes if it is unsupported
   * we need to conditionally set this hook for now until it is fixed in the library
   */
  // eslint-disable-next-line react-hooks/rules-of-hooks
  useResizeObserver__default.default({
    useDefaults: false,
    ref: resizeRef
  });
  return resizeRef;
};

exports.useResize = useResize;
