import React, { useEffect } from 'react'; import { View, Image, Animated } from 'react-native'; const Example1 = () => { const opacity = new Animated.Value(0); useEffect(() => { Animated.timing(opacity, { toValue: 1, duration: 1000, useNativeDriver: true, }).start(); }, []); return (); }; export default Example1;
import React, { useEffect } from 'react'; import { View, Animated } from 'react-native'; const Example2 = () => { const width = new Animated.Value(0); useEffect(() => { Animated.timing(width, { toValue: 200, duration: 1000, useNativeDriver: true, }).start(); }, []); return (In both examples, we use the Animated.timing method to animate the given value to the specified toValue over the specified duration. In the first example, we animate the opacity of an image, while in the second example we animate the width of a View. These examples use the React Native Animated module.); }; export default Example2;