mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
10 lines
191 B
TypeScript
10 lines
191 B
TypeScript
import { useRef } from 'react';
|
|
|
|
const useLatest = <T>(value: T): { readonly current: T } => {
|
|
const ref = useRef(value);
|
|
ref.current = value;
|
|
return ref;
|
|
};
|
|
|
|
export default useLatest;
|