Rotate animation — rotate element around axis.
Basic rotation:
1import { Animated, Easing } from "react-native";23const rotateAnim = useRef(new Animated.Value(0)).current;45function rotate() {6 Animated.timing(rotateAnim, {7 toValue: 1,8 duration: 1000,9 easing: Easing.linear,10 useNativeDriver: true,11 }).start();12}1314const rotation = rotateAnim.interpolate({15 inputRange: [0, 1],16 outputRange: ["0deg", "360deg"],17});1819<Animated.View style={{ transform: [{ rotate: rotation }] }}>20 <Text>Rotate me</Text>21</Animated.View>
Continuous rotation:
1const spinAnim = useRef(new Animated.Value(0)).current;23Animated.loop(4 Animated.timing(spinAnim, {5 toValue: 1,6 duration: 1000,7 easing: Easing.linear,8 useNativeDriver: true,9 })10).start();1112const spin = spinAnim.interpolate({13 inputRange: [0, 1],14 outputRange: ["0deg", "360deg"],15});