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

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;
};