"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useMemoImmer = void 0;
var react_1 = require("react");
var useDidUpdateDeepCompareEffect_1 = require("../useDidUpdateDeepCompareEffect");
function useMemoImmer(factory, deps) {
    var _a = react_1.useState(factory()), memo = _a[0], setMemo = _a[1];
    checkDeps(deps);
    useDidUpdateDeepCompareEffect_1.useDidUpdateDeepCompareEffect(function () {
        setMemo(factory());
    }, deps);
    return memo;
}
exports.useMemoImmer = useMemoImmer;
function checkDeps(deps) {
    if (!deps || !deps.length) {
        throw new Error('useMemoImmer should not be used with no dependencies. Use React.useEffect instead.');
    }
}
//# sourceMappingURL=useMemoImmer.js.map