Joe Robin
Joe Robin

Reputation: 153

How do I send current page no to onChange in Pagination fo material ui?

<Pagination
      count={pageCount}
      color="primary"
      onChange={() => props.onPageChange()}
 />

I am trying to send the current page number to onChange.

Upvotes: 5

Views: 11551

Answers (1)

Lazar Nikolic
Lazar Nikolic

Reputation: 4394

You should use it like this:

onChange={props.onPageChange}

and the onChange function should look like this:

onPageChange = (event, value)

Value parameter is the number of your current page that is exposed as an argument of this function by the Pagination component itself. See this code sendbox: https://codesandbox.io/s/bn7nw?file=/demo.js

Upvotes: 8

Related Questions