mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
14 lines
452 B
TypeScript
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;
|