source: imaps-frontend/node_modules/react-use/lib/usePreviousDistinct.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 691 bytes
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var react_1 = require("react");
4var useFirstMountState_1 = require("./useFirstMountState");
5var strictEquals = function (prev, next) { return prev === next; };
6function usePreviousDistinct(value, compare) {
7 if (compare === void 0) { compare = strictEquals; }
8 var prevRef = react_1.useRef();
9 var curRef = react_1.useRef(value);
10 var isFirstMount = useFirstMountState_1.useFirstMountState();
11 if (!isFirstMount && !compare(curRef.current, value)) {
12 prevRef.current = curRef.current;
13 curRef.current = value;
14 }
15 return prevRef.current;
16}
17exports.default = usePreviousDistinct;
Note: See TracBrowser for help on using the repository browser.