import _useSize2 from "ahooks/es/useSize";
import _useForceUpdate2 from "parsec-hooks/lib/forceUpdateHooks";
import { useEffect } from 'react';
export var getWH = function getWH(id) {
  return new Promise(function (resolve) {
    var _ref = document.getElementById(id) || {},
        offsetWidth = _ref.offsetWidth,
        offsetHeight = _ref.offsetHeight;

    resolve({
      width: offsetWidth || 0,
      height: offsetHeight || 0
    });
  });
};
export default (function (id) {
  var _useForceUpdate = _useForceUpdate2(),
      forceUpdate = _useForceUpdate.forceUpdate;

  var _useSize = _useSize2(document.getElementById(id)),
      width = _useSize.width,
      height = _useSize.height;

  useEffect(function () {
    if (height === undefined) {
      forceUpdate();
    }
  }, [width, height, forceUpdate]);
  return {
    width: width,
    height: height
  };
});