Skip to main content

onChange

Description

Fires when the current page is changed in the pager

Usage

onChange?: (ev: { value: number; from: number; to: number }) => void;

Parameters

The onChange handler receives a single object with the following properties:

  • value - (required) the number of the newly opened page
  • from - (required) the index of the first row on the new page
  • to - (required) the index of the last row on the new page

Example

function changeHandler(ev: { value: number; from: number; to: number }) {
const newState = ev;
console.log(newState);
// => { value: 2, from: 20, to: 40 }
}

<Pager value={2} total={100} onChange={changeHandler} />

Details

The onChange handler function receives an object with the number of the newly opened page and the indices of the start and end rows of this page.

Related article: Catching the change of the active page