"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useDelayedLoading = useDelayedLoading;
var _react = require("react");
/**
 * Returns true for the specified delay, then false.
 * Useful for preventing loading spinner flash on fast loads.
 */
function useDelayedLoading(delay, initialState = true) {
  const [isLoading, setIsLoading] = (0, _react.useState)(initialState);
  (0, _react.useEffect)(() => {
    if (!isLoading) return;
    const timeout = setTimeout(() => setIsLoading(false), delay);
    return () => {
      clearTimeout(timeout);
    };
  }, [isLoading, delay]);
  return isLoading;
}
//# sourceMappingURL=useDelayedLoading.js.map