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

Current page is reset to 1 on page load #18

Closed
muhammetsait opened this issue Feb 4, 2021 · 5 comments
Closed

Current page is reset to 1 on page load #18

muhammetsait opened this issue Feb 4, 2021 · 5 comments

Comments

@muhammetsait
Copy link

Hi! I was using this lib with Nextjs and I noticed that if the user requests a page like this:

localhost:3000/products?page=2

page=2 is loaded and then immediately setCurrentPage(1) callback is called, which causes page=1 to load instead.

I think it would be better if the paginator was able to keep the current page without going back to page=1 on first load.

@codenaz
Copy link
Owner

codenaz commented Feb 4, 2021

The Paginator component takes a currentPage prop, so you can write a useEffect or any logic that extracts the page you want to send the user to from your URL or anywhere else your app stores that data, and pass it to the currentPage prop. How you implement this is up to you since your app has access to update the currentPage prop.

@codenaz codenaz closed this as completed Feb 4, 2021
@codenaz
Copy link
Owner

codenaz commented Feb 13, 2021 via email

@codenaz codenaz reopened this Feb 13, 2021
@vikasg603
Copy link

Hey, @codenaz, any update on this issue?
I am getting lot's of the issue on NextJS because of this.

@TrejoCode
Copy link

@codenaz Any update? Please.

codenaz added a commit that referenced this issue Sep 22, 2021
#18 use current page prop before falling back to page 1 when setting initial page
@codenaz
Copy link
Owner

codenaz commented Sep 22, 2021

#30
This PR addresses the issue.

@codenaz codenaz closed this as completed Sep 22, 2021
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

4 participants