diff --git a/src/useUnmount.ts b/src/useUnmount.ts index 69df3b5f..74977cc1 100644 --- a/src/useUnmount.ts +++ b/src/useUnmount.ts @@ -1,9 +1,7 @@ -import {useEffect} from 'react'; +import useEffectOnce from './useEffectOnce' -const useUnmount = (unmount) => { - useEffect(() => () => { - if (unmount) unmount(); - }, []); +const useUnmount = (fn: () => void | undefined) => { + useEffectOnce(() => fn); }; export default useUnmount;