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.

How can I get the actual page from the onPageChange event?

See original GitHub issue

<Carousel onPageChange={ self.myFunction() }> { array } </Carousel>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
machadogjcommented, Aug 22, 2016

@sergioribeiro you can know that with the index passed in onPageChange. See this sample:

  state = {
    words: [
      'foo',
      'bar'
    ]
  };

  handleOnPageChange(pageIndex) {
    if (pageIndex === this.state.words.length - 1) {
      console.log('we reached the end!');
    }
  }

  render() {
    const pages  = this.state.words.map(w => <Text key={w}>{w}</Text>);
    return (
      <View style={styles.container}>
        <Carousel
          initialPage={ 1 }
          pageStyle={ {backgroundColor: 'white', borderRadius: 5} }
          onPageChange={ this.handleOnPageChange.bind(this) }
        >
          { pages }
        </Carousel>        
      </View>
    );
  }

Let me know if that helps.

0reactions
machadogjcommented, Aug 22, 2016

Welcome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get current page number onPagechange function in ...
Instead of onChange try calling onPageChange : ... `column` will be an array of columns onExpandedChange={(newExpanded, index, event) => {.
Read more >
if i use (pageChange)="onPageChange($event)" inside ...
if i use eventEmitter for ngb-pagination it causes my whole page to refresh on every ever.
Read more >
Pagination | Primer React
onPageChange, function, no-op, Called with event and page number when a page is clicked. showPages, boolean, true, Whether or not to show ...
Read more >
Data Grid - Pagination - MUI X
You can use the onPageChange prop to listen to changes to the page and update the prop accordingly. No rows.
Read more >
Set the page from last visit as the initial page
To track the current page, we can rely on the `onPageChange` event which is triggered when user changes page: import { PageChangeEvent, Viewer...
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