mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-22 09:56:57 +00:00
14 lines
234 B
TypeScript
14 lines
234 B
TypeScript
|
|
import { useEffect, useRef } from 'react';
|
||
|
|
|
||
|
|
function usePreviousValue<T>(value: T): T {
|
||
|
|
const ref = useRef<T>();
|
||
|
|
|
||
|
|
useEffect(() => {
|
||
|
|
ref.current = value;
|
||
|
|
}, [value]);
|
||
|
|
|
||
|
|
return ref.current as T;
|
||
|
|
}
|
||
|
|
|
||
|
|
export default usePreviousValue;
|