UNPKG

@gdjiami/hooks

Version:

react hooks for mygzb.com

13 lines (12 loc) 326 B
import { useEffect } from 'react'; import useRefProps from './useRefProps'; export default function useOnUnmount(fn) { var fnRef = useRefProps(fn); useEffect(function () { return function () { if (fnRef.current) { fnRef.current(); } }; }, []); }