Pagination Hook for React
Create paginated content with this easy to use React Hook
Installation
Add @mariosant/react-pagination-hook
to your package.json
.
$ npm install @mariosant/react-pagination-hook
You can now import the module and use it like
import usePagination from '@mariosant/react-pagination-hook';
const Component = ({data}) => {
const {
nextPage,
previousPage,
paginated,
} = usePagination(data) // data must be an array
return (
<div>
{paginated.map(record => (
<div key={record.key}>{record}</div>
))}
<button onClick={previousPage}>Previous</button>
<button onClick={nextPage}>Next</button>
</div>
)
You can also try in on CodeSandbox: https://codesandbox.io/s/74089wz7z1
Usage
WIP
Development
WIP
Meta
Marios Antonoudiou – @marios_ant – mariosant@sent.com
Distributed under the MIT license.
https://github.com/mariosant/react-pagination-hook
Contributing
- Fork it (https://github.com/mariosant/react-pagination-hook/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes using a semantic commit message.
- Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request