mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-24 07:28:28 +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;
|