Rocket.Chat.ReactNative/app/lib/hooks/usePrevious.ts

12 lines
199 B
TypeScript
Raw Normal View History

2024-01-25 14:11:07 +00:00
import { useEffect, useRef } from 'react';
export const usePrevious = (value: any) => {
const ref = useRef(value);
useEffect(() => {
ref.current = value;
}, [value]);
return ref.current;
};