source: imaps-frontend/node_modules/react-use/esm/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: 552 bytes
Line 
1import { useRef } from 'react';
2import { useFirstMountState } from './useFirstMountState';
3var strictEquals = function (prev, next) { return prev === next; };
4export default function usePreviousDistinct(value, compare) {
5 if (compare === void 0) { compare = strictEquals; }
6 var prevRef = useRef();
7 var curRef = useRef(value);
8 var isFirstMount = useFirstMountState();
9 if (!isFirstMount && !compare(curRef.current, value)) {
10 prevRef.current = curRef.current;
11 curRef.current = value;
12 }
13 return prevRef.current;
14}
Note: See TracBrowser for help on using the repository browser.