React-native-swiper: Swiper rendering last item first

Created on 7 Feb 2019  路  8Comments  路  Source: leecade/react-native-swiper

OS : Android and iOS

Version

Which versions are you using:

  • react-native-swiper v : 1.5.14
  • react-native v : 0.57.5

Expected behaviour

Swiper should show first item from the array

Actual behaviour

The active dot is at the first position but the image shown is from the last item of the array. On next swipe the first image gets rendered and active dot remains at the first position. On further swiping it works correct

Steps to reproduce: Set the height of the Swiper container, when height is not given in style, it works correct but takes a random height

Most helpful comment

same issue in Android

All 8 comments

Hello, can you solve it?

same issue in IOS.

same here, when the loop={true}

same issue in Android

I guess it show because of that ViewPagerAndroid setPage is asynchronous

I solved the issue isolating the Swiper in a class component and sending my information via props and applied a shouldComponentUpdate with this condition:

shouldComponentUpdate = nextProps => {
    return btoa(nextProps) !== btoa(this.props)
}

ps.: If the props are too long it will always return true, so I converted it to base64 to compare the returned strings.

Any easy fix on this ?

I find this repo https://github.com/f111fei/react-native-banner-carousel works which save my life

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chetanparakh picture chetanparakh  路  3Comments

itinance picture itinance  路  3Comments

diegolmello picture diegolmello  路  3Comments

nomoreboredom picture nomoreboredom  路  3Comments

ruben-kasaz picture ruben-kasaz  路  3Comments