12 lines
199 B
TypeScript
12 lines
199 B
TypeScript
|
import { useEffect, useRef } from 'react';
|
||
|
|
||
|
export const usePrevious = (value: any) => {
|
||
|
const ref = useRef(value);
|
||
|
|
||
|
useEffect(() => {
|
||
|
ref.current = value;
|
||
|
}, [value]);
|
||
|
|
||
|
return ref.current;
|
||
|
};
|