onIndexChanged errors
See original GitHub issueWhich OS
IOS
Version
Which versions are you using:
- react-native-swiper 1.15.13
- react-native v0.39
Expected behaviour
The onIndexChanged
should return correct values
Actual behaviour
I’m currently moving from one swiper to another and by doing this, functionality is broken
onIndexChanged={(index) => {
console.log('index >>> ', index);
this.setState({
currentPage: index
})
}}
'index >>> ', 1
'index >>> ', 2
'index >>> ', 0
'index >>> ', 3 // HERE JUMPS
jumps from 0 to 3, seems to try to continue from the value that was just before restarting the swiper
I have found other error scenarios
Examples:
in this case i have a fixed bottom view
let bottomView = <View style={{ flex: 0.08, backgroundColor: theme.colors.transparent }} />;
In this case the bottom view only appear when last active dot comes in.
bottomView = null
I get the impression that every time the NEXT button appears and updates the ui, the swiper breaks
Example code:
buildOnboardingSteps(currentSection) {
let { lastPage, title, baseText, swiperImages } = this.applyViewRenderValidations(currentSection);
let bottomView = null; // Second Gif
// let bottomView = <View style={{ flex: 0.08, backgroundColor: theme.colors.transparent }} />; // First gif
if (this.state.currentPage === lastPage) {
bottomView = (
<TouchableOpacity style={[styles.bottomView]} onPress={() => { this.passToNextSection() }}>
<Text style={[styles.baseText, styles.nextText]}>{'NEXT'}</Text>
</TouchableOpacity>
)
}
return (
<Animatable.Image style={styles.container} source={undefined} animation={'slideInRight'} duration={500}>
<View style={[styles.topView, styles.topViewAddItem]}>
<Text style={styles.baseTitle}>{title}</Text>
<Text style={styles.baseText}>{baseText}</Text>
<Swiper
style={styles.wrapper}
activeDotColor={theme.colors.swiperDotColor}
showsPagination={true}
scrollsToTop={true}
loop={false}
onIndexChanged={(index) => {
console.log('index >>> ', index);
this.setState({
currentPage: index
})
}}
>
{swiperImages}
</Swiper>
</View>
{bottomView}
</Animatable.Image>
)
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:7
Top Results From Across the Web
OnSelectedIndexChanged error - MSDN - Microsoft
Hi guys. I am getting this error in my DDL. Could someone please help me with this? Compiler Error Message: CS1061: 'ASP.shopping_cart_aspx' ...
Read more >C# ASP.Net - ListBox - onSelectedIndexChanged causes error
I am quite new to ASP.Net and I am trying to create a DataList on one of the pages, feed it from code...
Read more >RadListBox OnSelectedIndexChanged JS Error - Telerik
OnSelectedIndexChanged does not fire an event at all and OnClientSelectedIndexChanged gives a JS error. I'm using the RadListBoxes to move ...
Read more >Populating C1Combbox with Data Using the ... - GrapeCity
To populate the C1ComboBox with data once a specific index in the combo box has been selected, use the SelectedIndexChanged event like the...
Read more >ASPxCallbackPanel - A script error occurs when calling ...
I have a page with a combo box on it. It is wrapped in an ASPxCallback panel. I reference the callback in the...
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
Using
state
,onIndexChange/setState
, andindex
prop, AND giving theSwiper
an explicitwidth
prop that’s notfalsy
fixed this for me, as well.hi @chixpc123 .
I found a solution, but in a very unorthodox way.
Clearly, as is the code of my example, it should be enough for it to work, but I had to resort to 3 things:
Use the basic prop
index
, so every time I was updating the index with theonIndexChange
that value put it as the index prop of the swiper.Give it a
width
. As a direct prop in theswiper
instead a width insidestyle
. You can see it inCustom basic style & content
.In my code the view container of the swiper had a
paddingLeft
I had to remove it and give the margins to the left to each child in theswiper