usePrevious.ts 194 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 9 import { useRef, useEffect } from "react"; export function usePrevious<T>(value: T) { const ref = useRef<T>(); useEffect(() => { ref.current = value; }); return ref.current as T; }