leecade / leecade/react-native-swiper

onIndexChanged getting wrong value

Open
#1,371 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.5k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Swiper usage shown in the issue and create a minimal reproduction in the examples folder on iOS 16. Record the react-native-swiper and React Native versions, then verify the onIndexChanged sequence and the reported playback and previous-slide behavior; done means the reproduction no longer shows the inconsistent callback values.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.