Created
January 21, 2020 22:13
-
-
Save maisonm/ac0f644418333e46dfd07fd34e68e197 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
setCurrentClickedNumber = e => { | |
const { target } = e; | |
this.setState({ | |
currentClickedNumber: parseInt(target.innerText) | |
}); | |
}; | |
moveToLastPage = () => { | |
this.setState({ | |
currentClickedNumber: this.state.totalPages, | |
currentClickedPage: this.state.totalPages | |
}); | |
}; | |
moveToFirstPage = () => { | |
this.setState({ | |
currentClickedNumber: 1, | |
currentClickedPage: 1 | |
}); | |
}; | |
moveOnePageForward = () => { | |
const { dataStartingIndex, totalPages } = this.state; | |
if (dataStartingIndex) { | |
this.setState({ | |
dataStartingIndex: null, | |
currentClickedNumber: 2 | |
}); | |
} else { | |
this.setState({ | |
currentClickedNumber: | |
this.state.currentClickedNumber + 1 > totalPages | |
? totalPages | |
: this.state.currentClickedNumber + 1 | |
}); | |
} | |
}; | |
moveOnePageBackward = () => { | |
this.setState({ | |
currentClickedNumber: | |
this.state.currentClickedNumber - 1 < 1 | |
? 1 | |
: this.state.currentClickedNumber - 1 | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment