react-js-pagination
react-js-pagination copied to clipboard
Don't Receive pageNumber as arg by hooks
Hi, I Used react-js-pagination in my function Component ,but onChange return undefined for me.
<Pagination activePage={pageNumber} itemsCountPerPage={pageSize} totalItemsCount={totalRows} pageRangeDisplayed={5} onChange={() => handleSearch(this)} /> Can you help me? Best Rigards
Hello,
I know this post is kinda old and you may have found a solution (by using the class component maybe). Still, I ran into the same issue and found a solution, I hope this will help some people! :) On an other way, since I'm still kinda a beginner at react concepts, I can't explain in details why this works... Would love to see someone improve this answer!!!
let [activePage, setActivePage] = useState(1);
// ...
return (
<Pagination
activePage={activePage}
itemsCountPerPage={10}
totalItemsCount={450}
pageRangeDisplayed={5}
onChange={(e: number) => setActivePage(e)}
/>
)