react-js-pagination
react-js-pagination copied to clipboard
Change activePage but Paga not change
Please help me. When I change activePage but Paga not change
import React, { Component } from 'react'; import Pagination from 'react-js-pagination';
class MyComponent extends Component { constructor(props) { super(props); this.state = { activePage: 1 }; this.handlePageChange = this.handlePageChange.bind(this); }
handlePageChange(pageNumber) { this.setState({ activePage: pageNumber }); }
goToNextPage() { const newActivePage = this.state.activePage + 1; this.handlePageChange(newActivePage); }
render() { return (
<Pagination
key={this.state.activePage}
activePage={this.state.activePage}
itemsCountPerPage={10}
totalItemsCount={450}
pageRangeDisplayed={5}
onChange={this.handlePageChange}
/>
<button onClick={() => this.goToNextPage()}>Next page
);
}
}