Skip to content

Commit

Permalink
fix(pagination): only update if currentPage state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz committed Jul 11, 2018
1 parent 9c656f2 commit 63de823
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Pagination/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class Pagination extends React.Component {
}
}

shouldComponentUpdate(nextProps, nextState) {
// Update only when the props and currentPage state changes to avoid re-render
// if only the pageButtonSelected state is changed.
return nextProps !== this.props || nextState.currentPage !== this.state.currentPage;
}

componentDidUpdate() {
const { currentPage, pageButtonSelected } = this.state;
const currentPageRef = this.pageRefs[currentPage];
Expand Down

0 comments on commit 63de823

Please sign in to comment.