18 lines
603 B
JavaScript
18 lines
603 B
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.usePrevious = void 0;
|
||
|
var react_1 = require("react");
|
||
|
/**
|
||
|
* Hook keeping track of a given value from a previous execution of the component the Hook is used in.
|
||
|
*
|
||
|
* See [React Hooks FAQ](https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state)
|
||
|
*/
|
||
|
function usePrevious(value) {
|
||
|
var ref = (0, react_1.useRef)();
|
||
|
(0, react_1.useEffect)(function () {
|
||
|
ref.current = value;
|
||
|
});
|
||
|
return ref.current;
|
||
|
}
|
||
|
exports.usePrevious = usePrevious;
|
||
|
//# sourceMappingURL=usePrevious.js.map
|