mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-10 01:30:58 +00:00
12 lines
229 B
TypeScript
12 lines
229 B
TypeScript
![]() |
import { useLayoutEffect, useRef } from 'react';
|
||
|
|
||
|
const useLatest = <T>(value: T) => {
|
||
|
const ref = useRef(value);
|
||
|
useLayoutEffect(() => {
|
||
|
ref.current = value;
|
||
|
});
|
||
|
return ref;
|
||
|
};
|
||
|
|
||
|
export default useLatest;
|