import React from "react"; import { View, StyleSheet } from "react-native"; import MaskedView from "@react-native-masked-view/masked-view"; import { LinearGradient } from "react-native-linear-gradient"; import Reanimated,{ useSharedValue, withRepeat, useAnimatedStyle, withTiming, interpolate } from "react-native-reanimated"; interface SkeletonProps { /** * background of the loader componenet hexcode */ background: string, /** * highlight color of the loader component hexcode */ highlight: string } const SkeletonLoading: React.FC = ({ children, background, highlight }) => { const [layout, setLayout] = React.useState(); const shared = useSharedValue(0); const animStyle = useAnimatedStyle(() => { const x = interpolate( shared.value, [0, 1], [layout ? -layout.width : 0, layout ? layout.width : 0], ) return { transform: [ { translateX: x }, ] } }); React.useEffect(() => { shared.value = withRepeat( withTiming(1, { duration: 1000 }), Infinity, ); }, []); if (!layout) { return ( setLayout(event.nativeEvent.layout)}> {children} ); } return( } > ) } export default SkeletonLoading; const styles = StyleSheet.create({ container: { flexGrow: 1, overflow: 'hidden' } })