"use strict";
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useInterval = void 0;
var react_1 = require("react");
function useInterval(milliseconds) {
    var timer;
    var _a = __read((0, react_1.useState)(0), 2), count = _a[0], setCount = _a[1];
    var updateCount = function () {
        timer =
            !timer &&
                setInterval(function () {
                    setCount(function (prevCount) { return prevCount + 1; });
                }, milliseconds);
    };
    (0, react_1.useEffect)(function () {
        updateCount();
        return function () { return clearInterval(timer); };
    }, [count]);
    return { count: count };
}
exports.useInterval = useInterval;
//# sourceMappingURL=useInterval.js.map