优化
This commit is contained in:
8
client/shared/hooks/useUpdateRef.ts
Normal file
8
client/shared/hooks/useUpdateRef.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { useRef, MutableRefObject } from 'react';
|
||||
|
||||
export function useUpdateRef<T>(state: T): MutableRefObject<T> {
|
||||
const ref = useRef<T>(state);
|
||||
ref.current = state;
|
||||
|
||||
return ref;
|
||||
}
|
||||
Reference in New Issue
Block a user