BlueWallet/hooks/useAnimateOnChange.ts
Marcos Rodriguez Velez 0feb5939b7 wip
2024-09-27 08:08:42 -04:00

14 lines
452 B
TypeScript

import { useEffect, useRef } from 'react';
import { LayoutAnimation } from 'react-native';
const useAnimateOnChange = <T>(value: T) => {
const prevValue = useRef<T | undefined>(undefined);
useEffect(() => {
if (prevValue.current !== undefined && prevValue.current !== value) {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
}
prevValue.current = value;
}, [value]);
};
export default useAnimateOnChange;