"use strict";

exports.__esModule = true;
exports.useNetwork = useNetwork;
exports.default = void 0;

var _react = require("react");

function useNetwork() {
  const [isOnline, setNetwork] = (0, _react.useState)(window.navigator.onLine);

  const updateNetwork = () => {
    setNetwork(window.navigator.onLine);
  };

  (0, _react.useEffect)(() => {
    window.addEventListener('offline', updateNetwork);
    window.addEventListener('online', updateNetwork);
    return () => {
      window.removeEventListener('offline', updateNetwork);
      window.removeEventListener('online', updateNetwork);
    };
  });
  console.warn({
    isOnline
  });
  return isOnline;
}

var _default = useNetwork;
exports.default = _default;