React-native-pager-view: setPage isn't properly working in IOS

Created on 15 Jan 2020  路  3Comments  路  Source: callstack/react-native-pager-view

Bug

I'm implementing the sets of pages according to sections. When one section is completed the next section will been shown and it's start from zero page and so forth. It's working fine in Android but facing issue in IOS when i changed page number to zero after reaching last index of one section let say 3(length of section and first index is zero) and call other section and it should start from zero but it's not. I consoled page number in onPageSelected it show 0 but instantly it's called again and display 2(which was last index of previous section) i don't know why it's happening. It shouldn't run two times.

Environment info

"@react-native-community/viewpager": "^3.3.0",
"react": "16.8.6",
"react-native": "0.60.5",

Needs Repro

All 3 comments

@troZee here is sample code.
length= length of current section
this.i = index of current page

if (this.i != length - 1) {
    this.i = ++this.i;
    this.refs.viewPager.setPage(this.i);
  } else {
    var s = this.getNextSection();
    this.i = 0;
    this.refs.viewPager.setPage(this.i);
    if (s === null) {
  } else {
    this.setState({section: s, loading: false});
  }
}

This issue looks like a question that would be best asked on聽StackOverflow.
StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.
Will close this as this is really a question that should be asked on StackOverflow.

@iqbalfaisal im facing the same issue. Did you find a solution to this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefan-girlich picture stefan-girlich  路  9Comments

ferrannp picture ferrannp  路  10Comments

troZee picture troZee  路  3Comments

thecodecafe picture thecodecafe  路  4Comments

troZee picture troZee  路  8Comments