UNPKG

@figliolia/react-hooks

Version:

A small collection of simple React Hooks you're probably rewriting on a regular basis

10 lines (9 loc) 266 B
import { useEffect, useRef } from "react"; export const useUnmount = (onUnmount) => { const callback = useRef(onUnmount); callback.current = onUnmount; useEffect(() => { const { current: fn } = callback; return () => fn(); }, []); };