leecade / react-native-swiper

The best Swiper component for React Native.
MIT License
10.42k stars 2.34k forks source link

Render First Initial index != 0 #1098

Open lillogoal opened 5 years ago

lillogoal commented 5 years ago

Which OS ?

Android and maybe too IOS

Version

Which versions are you using: "react": "16.9.0", "react-native": "0.61.3", "react-native-swiper": "1.6.0-rc.3",

Expected behaviour

This is my Component where i use Swiper. <View style={{ flex: 1 }}> <Swiper style={styles.wrapper} showsButtons={false} index={1} ref={(ref: Swiper) => { this.swiperMain = ref }} horizontal={true} onIndexChanged={index => this.onIndexChanged(index)} showsPagination={false}

<Profile next={this.goNext} back={this.goBack} navigation={this.props.navigation} /> <HomeView next={this.goNext} back={this.goBack} navigation={this.props.navigation} /> <PromoView next={this.goNext} back={this.goBack} navigation={this.props.navigation} />

I setted initial index = 1 ad it's ok. But when i launch app (in particular in android) i can see before render index = 1, swiper renders index = 0 in my case Profile. I have been looked for solving this problem on github or google but i didn't find anything

I can record a little video if you want

lillogoal commented 5 years ago

In this moment i solved using this answer: https://github.com/facebook/react-native/issues/6849#issuecomment-513902755

But i think the problem is only in Android because not exist a method to set initial position ScrollView

yelkamel commented 4 years ago
"react-native": "0.61.2",
"react-native-swiper": "^1.6.0-rc.3",

Same issue here with Android. The workarround with the overlay work but need a better solution...

ChristianChiarulli commented 4 years ago

this only happens when I first map some data to a list of components

{array.map(a => (
          <Text>{a}</Text>
        ))}

If I just pass a bunch of views initially onIndexChange works as expected.