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

Force new current page as property #9

Closed
ragingsquirrel3 opened this issue Apr 8, 2015 · 4 comments
Closed

Force new current page as property #9

ragingsquirrel3 opened this issue Apr 8, 2015 · 4 comments

Comments

@ragingsquirrel3
Copy link

I understand that when the component mounts, I can pass initialPage as a property. After that, the current page is determined by internal state. For me, the problem is that I want to reset the current page from the parent (as a property).

My use case is paginated search results, and I want to always be on the first page after a new search. Right now, it seems I can only do this by unmounting the paginate component, and passing a new initialPage.

The solution, for me, would be to have an optional currentPage property, which, if absent, would defer to existing behavior.

@AdeleD
Copy link
Owner

AdeleD commented Apr 9, 2015

I understand. Thank you for your PR ;)

@AdeleD AdeleD closed this as completed Apr 9, 2015
@cAstraea
Copy link

Hello Travis , sorry to bother you.
Did you find a solution for this? Could you confirm if we're having the same problem http://recordit.co/TU5Wy2OI5W ?

I'm trying out your solution with ReactDOM.unmountComponentAtNode(document.getElementById('react-paginate'));
but need to make some changes to the search component to move it outside the paginate component first.

@sami616
Copy link

sami616 commented Aug 28, 2018

This approach seemed to work for me when needing to update the selected page based on a prop condition

  let forcePageObj = {}
  if (props.page === 0) {
    forcePageObj['forcePage'] = 0
  }

  return (
      <ReactPaginate
        onPageChange={handlePageChange}
        pageRangeDisplayed={3}
        marginPagesDisplayed={1}
        {...forcePageObj}
        pageCount={props.nbPages}
      />
  )

@yogitaba-gohil
Copy link

works for me

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

5 participants