import React, {useEffect, useRef} from 'react'; import {Animated, StyleSheet} from 'react-native'; import ProgressBar from './ProgressBar'; type Props = { next: () => void; pause: boolean; isLoaded: boolean; isNewStory: boolean; duration: number; stories: Array; currentStory: Object; currentIndex: number; length: Array; progress: Object; }; const ProgressArray = (props: Props) => { const opacity = useRef(new Animated.Value(1)).current; useEffect(() => { if (props.pause) { Animated.timing(opacity, { toValue: 0, duration: 300, useNativeDriver: true, }).start(); } else { Animated.timing(opacity, { toValue: 1, duration: 300, useNativeDriver: true, }).start(); } }, [props.pause]); return ( {props.length.map((i: number, index) => ( ))} ); }; const styles = StyleSheet.create({ progressBarArray: { flexDirection: 'row', position: 'absolute', top: 30, width: '98%', height: 10, justifyContent: 'space-between', alignItems: 'center', }, }); export default ProgressArray;