source: imaps-frontend/node_modules/react-use/esm/useUnmount.js@ d565449

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

Update repo after prototype presentation

  • Property mode set to 100644
File size: 362 bytes
RevLine 
[d565449]1import { useRef } from 'react';
2import useEffectOnce from './useEffectOnce';
3var useUnmount = function (fn) {
4 var fnRef = useRef(fn);
5 // update the ref each render so if it change the newest callback will be invoked
6 fnRef.current = fn;
7 useEffectOnce(function () { return function () { return fnRef.current(); }; });
8};
9export default useUnmount;
Note: See TracBrowser for help on using the repository browser.