React-native-swiper: Swiper on button click jumps 2 slides

Created on 18 Sep 2018  ·  6Comments  ·  Source: leecade/react-native-swiper

Which OS ?

ios and android

Version

Which versions are you using:

  • react-native-swiper v1.5.13
  • react-native v0.56.0

Expected behaviour

On click the button go to the next slide

Actual behaviour

When i click to the button on the first time it jumps to the same slide again

How to reproduce mit>

To help us, please fork this component, modify one example in examples folder to reproduce your issue and include link here.
-

Steps to reproduce

  1. yarn add react-native-swiper
  2. Create a component like this
  3. 3.
<Swiper
 height={140}
 showsButtons
>
  <Text>Slide 1</Text>
  <Text>Slide 2</Text>
</Swiper>

4.Click on the button to go to the next slide

kapture 2018-09-18 at 1 17 40

Most helpful comment

720

All 6 comments

me to

same here. Anyone found a workaround?

same here

add the key to the Swiper componet
like this:

<Swiper
        key={this.state.productImages.length}  // focus
        style={styles.swiper}
>
        {swiperItems}
</Swiper>

or like this:

const swiperItems = this.state.productImages.map(item => {
        return(
                <Image 
                        source={{uri: item.realpath}}
                        style={styles.swiperimage}
                        key={item.position}  // focus
                />
        )
})

720

Was this page helpful?
0 / 5 - 0 ratings