0
mmaidangzhu
The useLatest function takes a value and creates a reference to it. Then, it updates the "current" property of the reference to the given value.
Library: react
react
0 Comments
import { useRef } from 'react'; import { useRef } from 'react'; function useLatest<T>(value: T) { const ref = useRef(value); ref.current = value; return ref; } export default useLatest;