react-pagination-new
Version:
A simple and customizable pagination component for React applications.
51 lines (35 loc) • 1.35 kB
Markdown
A simple and customizable pagination component for React applications. This package allows you to easily implement pagination in your React projects with configurable page numbers, active states, and page change handling.
To install the `react-pagination-new` package, you can use npm or yarn:
```bash
npm install react-pagination-new
```
```bash
import { useState } from 'react';
import Pagination from 'react-pagination-new';
const YourComponent = () => {
const itemsPerPage = 4;
const [currentPage, setCurrentPage] = useState(1);
// Assuming you have your data in `whole_data` (e.g., an array of items)
const totalPages = Math.ceil(whole_data?.length / itemsPerPage);
const handlePageChange = (page) => {
setCurrentPage(page);
};
return (
<div>
{/* Render your items here */}
<Pagination
totalPages={totalPages}
currentPage={currentPage}
onPageChange={handlePageChange}
/>
</div>
);
};
```