"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useUpdateLayoutEffect = void 0;
const react_1 = require("react");
/**
 * A custom useEffect hook that only triggers on updates, not on initial mount
 * Idea stolen from: https://stackoverflow.com/a/55075818/1526448
 * @param {()=>void} effect the function to call
 * @param {Array<any>} dependencies the state(s) that fires the update
 */
function useUpdateLayoutEffect(effect, dependencies = []) {
    const isInitialMount = react_1.useRef(true);
    react_1.useLayoutEffect(() => {
        if (isInitialMount.current) {
            isInitialMount.current = false;
        }
        else {
            effect();
        }
    }, dependencies);
}
exports.useUpdateLayoutEffect = useUpdateLayoutEffect;
//# sourceMappingURL=useUpdateLayoutEffect.js.map