import React, {useState} from 'react'; import { ActivityIndicator, Image, type ImageErrorEventData, type NativeSyntheticEvent, StyleSheet, View, } from 'react-native'; const ProgressiveImage = (props: any) => { const [loading, setLoading] = useState(true); const fastImageItem = () => { return ( { setLoading(true); }} resizeMode={props.resizeMode || 'cover'} source={props.source} onLoadEnd={() => { setLoading(false); }} onError={(e: NativeSyntheticEvent) => { console.warn('slider image error :', e?.nativeEvent?.error); }} /> ); }; return ( {loading && !props.hideLoader && ( )} {fastImageItem()} ); }; const styles = StyleSheet.create({ container: { width: '100%', height: '100%', }, loadingContainer: { position: 'absolute', top: 0, width: '100%', height: '100%', backgroundColor: '#999', alignItems: 'center', justifyContent: 'center', }, }); export default ProgressiveImage;