feat: update
This commit is contained in:
13
src/hooks/use-previous.ts
Normal file
13
src/hooks/use-previous.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
function usePrevious<T>(value: T) {
|
||||
const ref = useRef<T>();
|
||||
|
||||
useEffect(() => {
|
||||
ref.current = value;
|
||||
}, [value]);
|
||||
|
||||
return ref.current;
|
||||
}
|
||||
|
||||
export default usePrevious;
|
||||
Reference in New Issue
Block a user