import React, { memo, useRef, useEffect } from 'react'; import { View, Animated, Platform, Easing } from 'react-native'; import type { LoadingIconProps } from './type'; const DURATION = 800; const Spinner = ({ color, size }: LoadingIconProps) => { const rotate = useRef(new Animated.Value(0)).current; const startRotation = React.useCallback(() => { Animated.loop( Animated.timing(rotate, { toValue: 1, duration: DURATION, // Animated.loop does not work if useNativeDriver is true on web useNativeDriver: Platform.OS !== 'web', easing: Easing.linear, }) ).start(); }, []); useEffect(() => { startRotation(); }, []); return ( {Array(12) .fill(null) .map((_, index) => ( ))} ); }; export default memo(Spinner);