"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useWindowDimensions = useWindowDimensions;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
var _react = _interopRequireWildcard(require("react"));
function getWindowDimensions() {
  var _window = window,
    width = _window.innerWidth,
    height = _window.innerHeight;
  return {
    width: width,
    height: height
  };
}
function useWindowDimensions() {
  var _useState = (0, _react.useState)(getWindowDimensions()),
    _useState2 = (0, _slicedToArray2.default)(_useState, 2),
    windowDimensions = _useState2[0],
    setWindowDimensions = _useState2[1];
  (0, _react.useEffect)(function () {
    function handleResize() {
      setWindowDimensions(getWindowDimensions());
    }
    window.addEventListener('resize', handleResize);
    return function () {
      return window.removeEventListener('resize', handleResize);
    };
  }, []);
  return windowDimensions;
}