UNPKG

@jay19950328/react-hooks

Version:
16 lines (13 loc) 300 B
import React from 'react'; function useUnmount(unmount) { var unmountRef = React.useRef(); unmountRef.current = unmount; React.useEffect(function () { return function () { if (unmountRef.current) { unmountRef.current(); } }; }, []); } export default useUnmount;