
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
react-responsive-pagination
Advanced tools
A React pagination component which intelligently renders to the available width.
Styled for Bootstrap 4.
Make sure your project is either using the Bootstrap 4 CSS styles or alternatively you can provide your own styles, see Requirements below
Include the pagination component in your React project with npm install react-responsive-pagination
Import the component with import Pagination from 'react-responsive-pagination'
Use the component with <Pagination current={currentPage} total={totalPages} onPageChange={pageChangeHandler} />
(see Usage Example for a more detailed example)
See the About Auto Sizing section below for info on some limitations of the auto sizing algorithm.
React 16.8 (the one with hooks)
Provide the correct styles in your project:
Modern browsers only - not suitable for IE 11
import React, { useState } from 'react';
import Pagination from 'react-responsive-pagination';
function MyApp() {
const [currentPage, setCurrentPage] = useState(4);
const totalPages = 17;
return (
<Pagination
current={currentPage}
total={totalPages}
onPageChange={setCurrentPage}
/>
);
}
Auto sizing uses the width of the immediate parent element. For best results make sure the parent element isn't intrinsically sized; that means the width of the parent element shouldn't depend on its contents. If your layout is intrinsic then the pagination component should still fill the space correctly but you may occasionally see inconsistant results or additional renders.
You can choose to override the auto sizing by specifying the maxWidth
prop (see Props section below).
The final thing to note is that for very narrow widths the component may exceed the available space - this is to ensure that there's always a usable pagination component.
Prop name | Type | Description |
---|---|---|
current | number | The current active page. Indexed from 1 |
total | number | The total number of pages |
onPageChange | (newPage: number) => void | A callback handler which is called when the user clicks a new page, note that the active page will not change unless the current prop is updated to reflect the new page (as in the example above). The newPage value is indexed from 1 |
maxWidth (optional) | number | (optional) The maximum width (in pixels) of the pagination component. Specify a value if you want to override the automatic sizing. Note this width may be exceeded in the case where it's not possible to output a small enough component |
FAQs
React component for responsive pagination
The npm package react-responsive-pagination receives a total of 4,839 weekly downloads. As such, react-responsive-pagination popularity was classified as popular.
We found that react-responsive-pagination demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.