Swiper as ListHeaderComponent in FlatList not rendering any image or text
I am trying to pass swiper as the header for a FlatList. My code work when i remove "
<View>
<FlatList
data = {this.state.mainImages}
renderItem = {({item}) => <View><Text>{item.image_slot_id}</Text></View>}
KeyExtractor={item => item.imgid}
ListHeaderComponent = {() => <RenderImages ImageDetails = {this.state.mainImages}/>}
/>
</View>
class RenderImages extends React.Component {
constructor(props){
super(props)
}
renderImagesSwipper() {
return(
this.props.ImageDetails.map(function(imgs){
return(
<View>
<Image
style={{height: 100}}
source={{uri: imgs.imgs_url}}
/>
</View>
)
})
)
}
render(){
return(
<View style={{height:200, width:400}}>
<Swiper loop={false} index={0}>
{this.renderImagesSwipper()}
</Swiper>
</View>
)
}
}
export default RenderImages;
You should set width & height to property instead of style.
How do I do that ? Property={{width:400, height:200}}?
the same question on android
add removeClippedSubviews={false} to FlatList,I solve it.
@xiaomaer your solution works for me, but in the docs, they mention that it could have bugs, I still didn't find a good solution to use Swiper and FlatList in ListHeaderComponent
same error, @leecade please help us.
@leecade