mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
33 lines
793 B
TypeScript
33 lines
793 B
TypeScript
import * as React from 'react';
|
|
import { Animated, ViewStyle } from 'react-native';
|
|
|
|
type AnimatedViewProps = {
|
|
fadeInDuration?: number;
|
|
style?: ViewStyle;
|
|
children: React.ReactNode;
|
|
useNativeDriver?: boolean;
|
|
};
|
|
|
|
export function AnimatedView(props: AnimatedViewProps) {
|
|
const fadeAnim = React.useRef(new Animated.Value(0)).current; // Initial value for opacity: 0
|
|
|
|
React.useEffect(() => {
|
|
Animated.timing(fadeAnim, {
|
|
toValue: 1,
|
|
duration: props.fadeInDuration ?? 250,
|
|
useNativeDriver: props.useNativeDriver ?? true,
|
|
}).start();
|
|
}, [fadeAnim, props.fadeInDuration, props.useNativeDriver]);
|
|
|
|
return (
|
|
<Animated.View
|
|
style={{
|
|
...props.style,
|
|
opacity: fadeAnim,
|
|
}}
|
|
>
|
|
{props.children}
|
|
</Animated.View>
|
|
);
|
|
}
|