UNPKG

@figliolia/react-hooks

Version:

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

14 lines (13 loc) 415 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useUnmount = void 0; const react_1 = require("react"); const useUnmount = (onUnmount) => { const callback = (0, react_1.useRef)(onUnmount); callback.current = onUnmount; (0, react_1.useEffect)(() => { const { current: fn } = callback; return () => fn(); }, []); }; exports.useUnmount = useUnmount;