Android
Which versions are you using:
Images change on swipe and after pressing buttons
onIndexChanged is triggered after pressing buttons, but the images does not change. It also shows only the last image instead of the first one for some reason.
This component used to work but after changing to newer version this problem occurred, I changed it back to ^1.5.14 but it works the same. It could be some external problem, but I tried changing styles and images, with little effect, so I think updating to 1.6.0-rc was source of the problem.
This is my code for reference:
<Swiper style={{
width: this.state.frameWidth,
height: this.state.imageHeight, alignSelf: 'center', alignItems: 'center',
}}
showsButtons={true}
showsPagination={false}
//renderPagination={( (index, total, context) => {this.renderPagination(index, total, context)})}
onIndexChanged={(index) => { this.setState({ index: index }) }}
buttonWrapperStyle={styles.buttonContainer}
dotColor={colors.white} activeDotColor={colors.darkPrimary}
nextButton={<View><Text style={styles.button}>›</Text></View>}
prevButton={<View><Text style={styles.button}>‹</Text></View>}
>
{
this.props.images.map((image, index) =>
<View key={index} style={{
alignSelf: 'center',
width: this.state.frameWidth,
height: this.state.imageHeight,
alignSelf: 'center', alignItems: 'center',
paddingBottom: 30,
//borderRadius: 20,
}}>
<Text>{index}</Text>
<Image source={image} style={{
width: this.state.imageWidth,
height: this.state.imageHeight,
borderRadius: 20,
}} />
</View>
)
}
</Swiper>
-
try not setting the width of Swiper styles. try setting the height only.
@nescroft It works
@nescroft it works
Thank you @nescroft
Most helpful comment
try not setting the width of Swiper styles. try setting the height only.