import React, { useEffect, useRef } from 'react'; import { Animated, Easing, View } from 'react-native'; const VbeSkeleton = ({ style, color="rgba(0, 10, 20, 0.05)", layout=[], widthList=["100%"], height=16, margin={}, borderRadius=8, animate=true }) => { const opacity = useRef(new Animated.Value(1)).current; useEffect(() => { if (animate) { startScanAnimate() } }, [animate]) const startScanAnimate = () => { Animated.timing(opacity, { toValue: 0.1, duration: 1000, easing: Easing.linear, useNativeDriver: true }).start(() => { if (animate) { endScanAnimate(); } }); } const endScanAnimate = () => { Animated.timing(opacity, { delay: 200, toValue: 1, duration: 1000, easing: Easing.linear, useNativeDriver: true }).start(() => { if (animate) { startScanAnimate(); } }); } if (layout.length > 0) { return ( { layout.map((item, index) => )} ) } else { return ( { widthList.map((item, index) => )} ); } }; export default VbeSkeleton;