UNPKG

@gechiui/compose

Version:
32 lines (26 loc) 719 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = usePrevious; var _element = require("@gechiui/element"); /** * GeChiUI dependencies */ /** * Use something's value from the previous render. * Based on https://usehooks.com/usePrevious/. * * @param value The value to track. * * @return The value from the previous render. */ function usePrevious(value) { const ref = (0, _element.useRef)(); // Store current value in ref. (0, _element.useEffect)(() => { ref.current = value; }, [value]); // Re-run when value changes. // Return previous value (happens before update in useEffect above). return ref.current; } //# sourceMappingURL=index.js.map