Files
chat/client/shared/hooks/useUpdateRef.ts
2026-04-25 16:36:34 +08:00

9 lines
188 B
TypeScript

import { useRef, MutableRefObject } from 'react';
export function useUpdateRef<T>(state: T): MutableRefObject<T> {
const ref = useRef<T>(state);
ref.current = state;
return ref;
}