onIndexChanged not called, wrong screen rendered
See original GitHub issueVersion
Which versions are you using:
- react-native-swiper v1.5.8
- react-native v0.47.1
Expected behavior
- onIndexChanged should be called when I swipe
- first View should be rendered as the first screen
Actual behavior
- not called
- third View (with “And simple” message) is rendered as first
Code example
export default class AppIntro extends PureComponent {
onSwipe = (index) => {
console.log('index changed', index);
}
render() {
return (
<Swiper style={styles.wrapper} onIndexChanged={this.onSwipe}>
<View style={styles.slide1}>
<Text style={styles.text}>Hello Swiper</Text>
</View>
<View style={styles.slide2}>
<Text style={styles.text}>Beautiful</Text>
</View>
<View style={styles.slide3}>
<Text style={styles.text}>And simple</Text>
</View>
</Swiper>
);
}
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:20
- Comments:31 (1 by maintainers)
Top Results From Across the Web
React Native swiper not working in StackNavigator for IOS
I Have found the solution. Add removeClippedSubviews={false} props to swiper. Then It will work.
Read more >Gridview's SelectedIndexChanged Event handler no longer ...
The ajax code is working, the selected row does highlight, ... but there is no longer a pop up details window when the...
Read more >T90752 Blender popup windows open on the wrong screen
open on the wrong monitor while the main screen of blender opens on the primary. ... Fix T88552: Cycles changing Render Passes in...
Read more >DataGrid controls display incorrectly in pages - ASP.NET
The data grid does not appear at all if: You do not set the DataSource property of the DataGrid control. Or. You do...
Read more >react-native-swiper-ajusted - npm
There are no other projects in the npm registry using ... correct the wrong types #1000; Add missing scrollBy TypeScript definition #931.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I know this is a really old thread, but I was having the same issue and none of the above solutions seemed to work… because it was just me being dumb. 🤦
tldr; you don’t appear to be able to change the number of slides on the fly my and on first render, I had zero.
My problem:
Basically I was creating a Swiper with zero slides, then a second later updating it with multiple slides. All I had to do was wait until I had the data to render the Swiper:
If
onIndexChanged
is not working than try to use