Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-pagination-bar
Advanced tools
Readme
Lightweight component for pagination of application pages on react
aria-*
attributes.Install the library using one of these commands:
$ npm i react-pagination-bar
# or
$ yarn add react-pagination-bar
To start using the library, add import Pagination and place the component in your code. If you are not going to customize the styles of the component, don't forget to add the default styles:
import 'react-pagination-bar/dist/index.css'
Simple usage without react-router-dom:
import { Pagination } from "react-pagination-bar"
import 'react-pagination-bar/dist/index.css'
const posts = [
{ id: 1, title: 'Post 1' },
{ id: 2, title: 'Post 2' },
{ id: 3, title: 'Post 3' },
{ id: 4, title: 'Post 4' },
{ id: 5, title: 'Post 5' },
{ id: 6, title: 'Post 6' },
{ id: 7, title: 'Post 7' },
{ id: 8, title: 'Post 8' },
{ id: 9, title: 'Post 9' },
{ id: 10, title: 'Post 10' },
{ id: 11, title: 'Post 11' },
{ id: 12, title: 'Post 12' },
];
export const App = () => {
const [currentPage, setCurrentPage] = useState(1);
const pagePostsLimit = 3;
return (
<div className="App">
{posts
.slice((currentPage - 1) * pagePostsLimit, currentPage * pagePostsLimit)
.map((post) => <div key={post.id}>{post.title}</div>)}
<Pagination
currentPage={currentPage}
itemsPerPage={pagePostsLimit}
onPageChange={(pageNumber) => setCurrentPage(pageNumber)}
totalItems={posts.length}
pageNeighbours={2}
/>
</div>
);
};
Prop name | Type | Default value | Description | Required |
---|---|---|---|---|
totalItems | Number | None | Total number of items on the server. | Yes |
onPageChange | ((pageNumber: number) => void) | None | Callback triggered on page change. | Yes |
currentPage | Number | 1 | Page number to be shown first. Be sure to synchronize the value with the server if you work with routing! | Yes |
itemsPerPage | Number | 10 | The number of items to display on your page. Be sure to synchronize the value with the server if you work with routing! | Yes |
startLabel | String | '<<' | The text of the button that sends to the first page. | No |
endLabel | String | '>>' | The text of the button that sends to the last page. | No |
prevLabel | String | '<' | The text of the button that sends to the previous page. | No |
nextLabel | String | '>' | The text of the button that sends to the next page. | No |
pageNeighbours | Number | 4 | The number of pages displayed next to the currently selected. | No |
withProgressBar | Boolean | false | Shows the progress bar under pagination. | No |
onlyPageNumbers | Boolean | false | Removes buttons and leaves only pages. | No |
onlyPaginationButtons | Boolean | false | Removes pages leaves only buttons. | No |
withGoToInput | Boolean | false | Shows the input field to go to the page. | No |
customClassNames | Object | *Take a look at the example with component customization* | Replaces default class names. | No |
Coming soon...
MIT © Ilya Sokol
FAQs
Functional page navigation bar for react
The npm package react-pagination-bar receives a total of 217 weekly downloads. As such, react-pagination-bar popularity was classified as not popular.
We found that react-pagination-bar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.