UNPKG

@schema-render/core-react

Version:

Through a set of simple JSON Schema, efficiently build a set of forms.

13 lines (12 loc) 396 B
import { useEffect } from "react"; import useLatest from "./useLatest"; /** * fork from https://github.com/alibaba/hooks/blob/master/packages/hooks/src/useUnmount/index.ts */ const useUnmount = (fn)=>{ const fnRef = useLatest(fn); useEffect(()=>()=>{ fnRef.current(); }, // eslint-disable-next-line react-hooks/exhaustive-deps []); }; export default useUnmount;