Closed ncampos92 closed 7 years ago
Hi @ncampos92, Yes you can. You can use any Touchable component, and im the onPress call the "goToPage" method. For calculating the next/previous item, you can use the "onPageChange" to update the index. you can wrap the component in a view, and then use position absolute to place your buttons wherever you want. Let me know if that helps.
Hi @machadogj im trying to call the goToPage method but im getting an error. I call "Carousel.goToPage(index)" and get "undefined is not a function". Can you help me with this?
Hi @ncampos92 you actually need to get a hold of the reference first. Something like this in your render method:
render() {
return (
<View.....>
<Carousel ref={ c => this.carousel = c } .... >....</Carousel>
</View>
);
}
And then you can do:
handleOnNext() {
this.carousel.goToPage(3); //whatever you need here.
}
Thanks @machadogj now i got it to work!
Sounds good!
I want to put a button in the carousel to go to the next or previous view, is this possible?