mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-18 03:14:07 +08:00
12 lines
230 B
TypeScript
12 lines
230 B
TypeScript
import { useRef, useEffect } from 'react';
|
|
|
|
const usePrevious = <T>(value: T): T | undefined => {
|
|
const ref = useRef<T>();
|
|
useEffect(() => {
|
|
ref.current = value;
|
|
});
|
|
return ref.current;
|
|
};
|
|
|
|
export default usePrevious;
|