npm.io
1.0.4 • Published 4 years ago

react-page-states

Licence
MIT
Version
1.0.4
Deps
0
Size
533 kB
Vulns
0
Weekly
0

react-page-states

React hook for bundling typical states used in table pagination

NPM JavaScript Style Guide

Install

npm install --save react-page-states
or
yarn add react-page-states

Features

  • pageNo and pageSize saved in url search params to handle page refresh

Usage

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();
}

API

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

License

MIT raphElzr