import { useState, useEffect } from 'react';
export default function useDelayed(_a) {
    var loading = _a.loading, delay = _a.delay;
    var shouldDelay = !!(delay && delay > 0);
    var _b = useState(shouldDelay), delayed = _b[0], setDelayed = _b[1];
    useEffect(function () {
        if (loading && shouldDelay) {
            setDelayed(true);
            var timerId_1 = setTimeout(function () { return setDelayed(false); }, delay);
            return function () { return clearTimeout(timerId_1); };
        }
        return setDelayed(shouldDelay);
    }, [loading, delay, shouldDelay]);
    return delayed;
}
