how to manually tell react-paginate to change its active page i

Viewed 17

So what im trying to do is once the user presses on a specific category i want to send him back to the first page, and that works by simply changing my current page number and i did it through this

const handleCategory = (category) => {
    SetPageNumber(0);
    if (category == 'All') allProducts();
    else {
       data
    }
 }

however react paginate page number wont change, how can i let react paginate know that i want to change the current active page

    <ReactPaginate
      previousLabel={"Previous"}
      nextLabel={"Next"}
      pageCount={pageCount}
      onPageChange={changePage}
      containerClassName={"paginationBttns"}
      previousLinkClassName={"previousBttn"}
      nextLinkClassName={"nextBttn"}
      disabledClassName={"paginationDisabled"}
      activeClassName={"paginationActive"}
    />

Example Scenario: User presses page 5 , and selects sofas as category , my code currently shows him data of sofas starting from page 1 however user sees that im currently still at page 5.

0 Answers
Related