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

Don't Receive pageNumber as arg by hooks #107

Open
elibh159 opened this issue May 27, 2020 · 1 comment
Open

Don't Receive pageNumber as arg by hooks #107

elibh159 opened this issue May 27, 2020 · 1 comment

Comments

@elibh159
Copy link

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

@Rdyx
Copy link

Rdyx commented Jul 27, 2020

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)}
      />
)

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

2 participants