Refactor useUnmount

This commit is contained in:
Ward Oosterlijnck 2019-03-31 20:01:31 +11:00
parent 236373bbed
commit 5284c8a4be

View File

@ -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;