React hook for bundling typical states used in table pagination
npm install --save react-page-states
or
yarn add react-page-states
- pageNo and pageSize saved in url search params to handle page refresh
Import the library and use the hook:
import * as React from 'react'
import { usePage } from 'react-page-states'
const Example = () => {
const { pageNo, pageSize, total, setPageNo, setPageSize } = usePage();
}
Property | Type | Default | Description |
---|---|---|---|
pageNo |
number |
1 |
Page number. |
pageSize |
number |
10 |
Page size. |
total |
number |
0 |
Used for computing max allowable pages. |
maxPage |
number |
0 |
Auto computed based on page size and total items. |
setPageNo |
() => void |
Sets page number value | |
setPageSize |
() => void |
Sets page size value | |
setTotal |
() => void |
Sets total value |
MIT © raphElzr