react-native-swiper icon indicating copy to clipboard operation
react-native-swiper copied to clipboard

Swiper as ListHeaderComponent in FlatList not rendering any image or text

Open chetanparakh opened this issue 9 years ago • 7 comments

I am trying to pass swiper as the header for a FlatList. My code work when i remove "" and "". But i want to have swiper imcluded so that i can also swipe between images and make this swiper scroll up when the flatList is scrolled up

  <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;

chetanparakh avatar Jul 17 '17 04:07 chetanparakh

You should set width & height to property instead of style.

jayasme avatar Jul 17 '17 05:07 jayasme

How do I do that ? Property={{width:400, height:200}}?

chetanparakh avatar Jul 17 '17 17:07 chetanparakh

the same question on android

lizhuoyuan avatar Aug 18 '17 05:08 lizhuoyuan

add removeClippedSubviews={false} to FlatList,I solve it.

xiaomaer avatar Sep 20 '17 07:09 xiaomaer

@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

Iliyass avatar Apr 26 '18 08:04 Iliyass

same error, @leecade please help us.

geminiyellow avatar Aug 24 '18 08:08 geminiyellow

@leecade

jimmybytes avatar Jan 14 '20 12:01 jimmybytes