import React, { memo, useRef, useEffect, useCallback } from 'react'; import { Animated, Easing } from 'react-native'; import { Svg, Circle } from 'react-native-svg'; const AnimateCircle = Animated.createAnimatedComponent(Circle); const AnimateSvg = Animated.createAnimatedComponent(Svg); const DURATION = 1400; const XTLoading = ({ color, size }: { color?: string; size?: number }) => { const strokeDash = useRef(new Animated.Value(0)).current; const rotate = useRef(new Animated.Value(0)).current; const startRotation = useCallback(() => { Animated.loop( Animated.timing(strokeDash, { toValue: 100, duration: DURATION, useNativeDriver: true, easing: Easing.inOut(Easing.ease), }) ).start(); Animated.loop( Animated.timing(rotate, { toValue: 1, duration: DURATION, useNativeDriver: true, easing: Easing.linear, }) ).start(); }, []); useEffect(() => { startRotation(); }, []); return ( ); }; export default memo(XTLoading);