I need to show the cards in app only when their images loaded successfully and if they are in loading state I want to show a loading indicator. so here's my implementation:
const [imageLoaded, setImageLoaded] = useState(false)
const images = props.companyImages.map((el, index) => {
return el.imageLink
})
const loaded = () => {
setImageLoaded(true)
}
return (
{!imageLoaded ?
<View style={styles.imageContainer}>
<BitSwiper
items={images.map((el, index) => index)}
showPaginate={false}
onItemRender={(item, index) => (
<View key={index} style={{ height: 200, overflow: 'hidden', borderTopRightRadius: 20, borderTopLeftRadius: 20 }}>
<Image
source={{ uri: images[index] }}
style={{ width: '100%', height: '100%', overflow: 'hidden' }}
onLoad={loaded}
/>
</View>
)}
/>
</View>
:
<ActivityIndicator color='red' />
}
but this doesn't work. any ideas?