wwwaiser / react-js-pagination

http://vayser.github.io/react-js-pagination
Creative Commons Zero v1.0 Universal
353 stars 95 forks source link

Prev/next key change causes unnecessary re-render #84

Open lorenzos opened 5 years ago

lorenzos commented 5 years ago

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.