question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onMomentumScrollEnd and OnIndexChanged not firing

See original GitHub issue

On Windows 10

  • react-native-swiper v1.5.12
  • react-native v0.48.4

Oddly enough I have the same code on two pages, with just basic views, and on one it fires, and on the other it doesn’t. I’m getting no logs for anything.

I can’t fork the code because it’s private, but this is the gist of the code. Working code

render() {
  return (
    <View style={styles.container}>
        <Header title={this.state.title} onPress={()=>this.props.navigation.goBack()}/>
        <View style={styles.body}>
            <View style={styles.routes}>
              <Swiper loadMinimal={true} loadMinimalSize={4} showsPagination={false}>
                  {this.display()}
              </Swiper>
            </View>
            <View style={styles.alpha}>
                {this.displayAlpha()}
            </View>
          </View>
      </View>
  )

Not working code

onMomentumScrollEnd = (e, state, context) => {
    Reactotron.log(this.state.List[state.index].title)
    Reactotron.log(true, true)
}
render() {
  return (
     <View style={styles.container}>
       <Header title={this.state.title} onPress={()=>this.props.navigation.goBack()} navigate={this.props.navigation.navigate}/>
       <View style={styles.body}>
          <View style={styles.routes}>
             <Swiper loadMinimal={true} loadMinimalSize={4} showsPagination={false} onMomentumScrollEnd={this.onMomentumScrollEnd}>
                   {this.display()}
             </Swiper>
          </View>
          <View style={styles.alpha}>
            {this.displayAlpha()}
          </View>
        </View>
      </View>
  )
}

this.display() returns an array of basic <Text></Text> like components.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
yashaROcommented, Oct 13, 2017

Well that was the root of my issue, retrieving the data on the screen caused it not to work, so I retrieved the data earlier and then propped it to the screen and it works.

1reaction
ravirupareliyacommented, Oct 4, 2017

Yes even in my case also it is not working. It is working fine if we are using static data, but not working when list is dynamic

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-swiper method scrollBy - Stack Overflow
If I click on index 0, 1 and 2 will stop working. If I click 2 times on 1 or 2, then the...
Read more >
react-native-swiper | Yarn - Package Manager
changelog · [1.6.0-dev]. ViewPagerAndroid: react-native => @react-native-community/viewpager · [1.5.14]. fixes #582 (Android not setting this onLayout first?) · [ ...
Read more >
react swiper active index | The AI Search Engine You Control
Margin,padding is not working ... PS: I tried to use onMomentumScrollEnd and onIndexChanged to monitor the index changes but neither works in the...
Read more >
pinar - npm
There are no other projects in the npm registry using pinar. ... onMomentumScrollEnd, (event) => void, function, Called when <ScrollView> 's ...
Read more >
ScrollView - React Native
If component have not been provided, the default ... Used to manually set the starting scroll offset. ... onMomentumScrollEnd ​.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found