Last active
May 11, 2017 17:08
-
-
Save fcgomes92/71313abb41e084d0396b7eb7dfc8fb0b to your computer and use it in GitHub Desktop.
react-paginate (https://github.com/AdeleD/react-paginate) example
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
class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
currentPage: 0, | |
pageCount: 10, | |
} | |
} | |
handlePageClick = (data) => { | |
this.setState({currentPage: data.selected}); | |
}; | |
handleOnClickButton = (goTo) => { | |
this.setState({ | |
currentPage: goTo, | |
}); | |
} | |
render() { | |
return ( | |
<div> | |
<button onClick={()=>{this.handleOnClickButton(0)}}>Go to Page 1</button> | |
<button onClick={()=>{this.handleOnClickButton(1)}}>Go to Page 2</button> | |
<ReactPaginate | |
pageCount={this.state.pageCount} | |
pageRangeDisplayed={5} | |
marginPagesDisplayed={2} | |
onPageChange={this.handlePageClick} | |
forcePage={this.state.currentPage} | |
previousLabel={"previous"} | |
nextLabel={"next"} | |
breakLabel={<a href="">...</a>} | |
breakClassName={"break-me"} | |
containerClassName={"pagination"} | |
subContainerClassName={"pages pagination"} | |
activeClassName={"active"}/> | |
</div>); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment