import { useEffect , useRef } from "react" ; export const useUnmount = ( cleanUpFn ) => { const ref = useRef ( cleanUpFn ) ; ref . current = cleanUpFn ; useEffect ( ( ) => { return ( ) => { ref . current ( ) ; } ; } , [ ] ) ; } ;