import { useEffect , useRef } from "react" ; link param { K } value returns { K | undefined } export const usePrevProps = < K = any > ( value ) => { const ref = useRef < K > ( ) ; useEffect ( ( ) => { ref . current = value ; } ) ; return ref . current ; } ;