UNPKG

@gilbarbara/hooks

Version:

Collection of useful React hooks

12 lines (8 loc) 183 B
import { useEffect, useRef } from 'react'; export function useLatest<T>(value: T) { const ref = useRef(value); useEffect(() => { ref.current = value; }); return ref; }