Created
February 22, 2019 23:22
-
-
Save zerostyle/75e672378ae5ef81a69874533dac9ac7 to your computer and use it in GitHub Desktop.
Pagination Previous and Next Pattern (React)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const previous = currentIndex => { | |
const { items, setActiveId } = this.props | |
const index = (currentIndex - 1 + items.length) % items.length | |
setActiveId(items[index].id) | |
} | |
const next = currentIndex => { | |
const { items, setActiveId } = this.props | |
const index = (currentIndex + 1) % items.length | |
setActiveId(items[index].id) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment