UNPKG

@figliolia/react-hooks

Version:

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

11 lines (9 loc) 265 B
import { useEffect, useRef } from "react"; import type { Callback } from "Types"; export const useMount = (onMount: Callback) => { const callback = useRef<Callback>(onMount); callback.current = onMount; useEffect(() => { callback.current(); }, []); };