import React, { useEffect, useRef } from 'react'; import { Animated, View } from 'react-native'; import { Icon } from '@ant-design/react-native' const RotatingIcon = () => { const spinAnim = useRef(new Animated.Value(0)).current; // 创建一个新的 Animated.Value 实例 useEffect(() => { Animated.loop( Animated.timing(spinAnim, { toValue: 1, duration: 800, useNativeDriver: true, // 这是推荐的做法 }) ).start(); }, [spinAnim]); const spin = spinAnim.interpolate({ inputRange: [0, 1], outputRange: ['0deg', '360deg'], }); return ( ); }; export default RotatingIcon;