Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onIndexChanged getting wrong value #1371

Open
shubh89193 opened this issue Apr 22, 2024 · 0 comments
Open

onIndexChanged getting wrong value #1371

shubh89193 opened this issue Apr 22, 2024 · 0 comments

Comments

@shubh89193
Copy link

Which OS ?

ios 16

Version

Which versions are you using:

  • react-native-swiper v?
  • react-native v0.?.?

Expected behaviour

onIndexChanged it should give me on every swipe one index but when I am swiping slide for first swipe 0 , second swipe 1 , for third swipe 1

Actual behaviour

onIndexChanged it should give me on every swipe one index but when I am swiping slide for first swipe 0 , second swipe nothing returning , for third swipe it returning 2 and goes on
due to this my logic working like this first video will playing 2nd video flicker and previous slide showing

How to reproduce it>

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

renderSwiperContent = () => {
console.log("current index on parent ",this.state.replayIndex)
return (

<Swiper
loop
style={styles.swiper}
dotStyle={styles.dot}
activeDotStyle={styles.activeDot}
paginationStyle={styles.pagination}
//ref={this.videoRef}

      index={this.state.replayIndex}
     // onIndexChanged={(index) => this.setState({ replayIndex: index })}
    >
      {this.state.profileImageAttachments.map((item, index) =>(
        <View key={item.id} style={styles.slide}>
          {item.attributes.media_type.startsWith('image') ? (
            <Image
              resizeMode="cover"
              source={{ uri: item.attributes.images_and_videos_upload }}
              style={styles.image}
            />
          ) : (
            <>
              <VideoComp
                  uri={item.attributes.images_and_videos_upload} 
                  index={index}
                  currentIndex={this.state.replayIndex}/>
            
            </>
          )}
        </View>
      ))}
    </Swiper>
  </View>
);

};

initial replayIndex = 0

Steps to reproduce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant