react-page-states
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

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


Readme

Keywords

none

Package Sidebar

Install

npm i react-page-states

Weekly Downloads

37

Version

1.0.4

License

MIT

Unpacked Size

546 kB

Total Files

22

Last publish

Collaborators

  • raphfuentes