UNPKG

@hakuna-matata-ui/hooks

Version:
12 lines (8 loc) 212 B
import { useRef, useEffect } from "react" export function usePrevious<T>(value: T) { const ref = useRef<T | undefined>() useEffect(() => { ref.current = value }, [value]) return ref.current as T }