react-js-pagination icon indicating copy to clipboard operation
react-js-pagination copied to clipboard

Prev/next key change causes unnecessary re-render

Open lorenzos opened this issue 5 years ago • 0 comments

The <Page> component's key for prev/next depends on the number of the prev/next page:

https://github.com/vayser/react-js-pagination/blob/bcd8c7f2440e48dd3379dcac4196cd5848539a31/src/components/Pagination.js#L135-L163

This causes the two components to be unnecessary re-rendered each time the page is changed. I noticed it because I placed icons as a custom elements for prevPageText, etc, and they "flash" on every page change, since they're reloaded every time on newly mounted HTML elements.

IMHO the key for those components should be just key={"prev"} and key={"next"}, similarly to how first/last work, where there's no issue.

lorenzos avatar Sep 19 '19 16:09 lorenzos