mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-08 00:28:37 +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;
|