Open quentinpaden opened 7 years ago
Hi, you can use getCurrentPage().
getCurrentPage()
Example:
setCarouselRef = (ref) => { this.carousel = ref } getCurrentPage() { return this.carousel && this.carousel.getCurrentPage() } render() { return ( <View style={{ flex: 1 }} onLayout={this._onLayoutDidChange}> <Carousel delay={2000} style={this.state.size} autoplay pageInfo onAnimateNextPage={(p) => console.log(p)} ref={this.setCarouselRef} > <View style={[{ backgroundColor: '#BADA55' }, this.state.size]}><Text>1</Text></View> <View style={[{ backgroundColor: 'red' }, this.state.size]}><Text>2</Text></View> <View style={[{ backgroundColor: 'blue' }, this.state.size]}><Text>3</Text></View> </Carousel> </View> ); }
Thank you so much, you are awesome!
If you don't mind me asking, how would you put that method into a text component? It keeps telling me it's unidentified.
Hi, you can use
getCurrentPage()
.Example: