Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lorenzos opened this issue Sep 19, 2019 · 0 comments
Open

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

lorenzos opened this issue Sep 19, 2019 · 0 comments

Comments

@lorenzos
Copy link

lorenzos commented Sep 19, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant