The swiper index value comes out in order of page order. However, when the button is pressed, the index value goes up to infinity.
ex) next button click-> 6/5, 7/5, 8/5
What I would like to do is stop the button event on 5/5 but I do not know what to do.
https://github.com/leecade/react-native-swiper
App.js
const renderPagination = (index, total, context) => {
return (
<View style={styles.paginationStyle}>
<Text style={{ color: 'grey' }}>
<Text style={styles.paginationText}>{index + 1}</Text>/{total}
</Text>
</View>
)
}
export default class App extends Component {
constructor(props){
super(props);
this.onPressNext = this.onPressNext.bind(this);
this.state = {
idxActive: 1
}
}
onPressPrev = () => {
this.refs.swiper.scrollBy(-1)
}
onPressNext = () => {
this.refs.swiper.scrollBy(1);
}
render() {
return (
<View style={styles.container}>
<Swiper
style={styles.wrapper}
renderPagination={renderPagination}
showsButtons={false}
loop={false}
ref={'swiper'}
>
<View style={styles.slide}>
<Text style={styles.text}>1 page</Text>
</View>
<View style={styles.slide}>
<Text style={styles.text}>2 page</Text>
</View>
<View style={styles.slide}>
<Text style={styles.text}>3 page</Text>
</View>
<View style={styles.slide}>
<Text style={styles.text}>4 page</Text>
</View>
<View style={styles.slide}>
<Text style={styles.text}>5 page</Text>
</View>
</Swiper>
<View style={styles.buttoncontainer}>
<Button
onPress={this.onPressPrev}
title="previous">
</Button>
<Button
onPress={this.onPressNext}
title="next">
</Button>
</View>
</View>
);
}
}