Android
Which versions are you using:
"react-native-swiper": "^1.5.14",
react-native-cli: 2.0.1
react-native: 0.55.4
when swiping the Img call the onIndexChanged function
onIndexChanged not firing function
**
loop={false} showsPagination ={true}
renderPagination={renderPagination}
key={this.state.gallaryData.length}
onIndexChanged = {(index) => this.changeSlide(index)}
>
{data.map((item, key) => {
return (
)
})}
</Swiper>**
-
I think you have the same problem as me. I figured that the this.onLayout() is triggered once where your data has the length of 1. Which means the offset is an empty object.
I did a workaround. After I update my data I trigger following (make sure you created an ref to the Swiper component:
const layout = Dimensions.get('window');
const data = await newDate();
this.swiper.current.setState({
index: 0, // or any other index
total: data.length,
}, () => {
this.swiper.current.onLayout({ nativeEvent: { layout } });
});
@JPeer264 adding key={this.state.gallaryData.length} in swiper it's working Thnks.
Most helpful comment
@JPeer264 adding key={this.state.gallaryData.length} in swiper it's working Thnks.