UNPKG

@taro-hooks/ahooks

Version:
17 lines 554 B
import { useEffect } from '@taro-hooks/core'; import useLatest from '../useLatest'; import { isFunction } from '@taro-hooks/shared'; var useUnmount = function useUnmount(fn) { if (process.env.NODE_ENV === 'development') { if (!isFunction(fn)) { console.error("useUnmount expected parameter is a function, got " + typeof fn); } } var fnRef = useLatest(fn); useEffect(function () { return function () { fnRef == null ? void 0 : fnRef.current == null ? void 0 : fnRef.current(); }; }, []); }; export default useUnmount;