From 63de823d224b5d7ad9674d7018c2af9a9acbf27f Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Wed, 11 Jul 2018 16:51:16 -0400 Subject: [PATCH] fix(pagination): only update if currentPage state changes --- src/Pagination/index.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Pagination/index.jsx b/src/Pagination/index.jsx index 6d872aba92..be5e6a5e0e 100644 --- a/src/Pagination/index.jsx +++ b/src/Pagination/index.jsx @@ -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];