Current collected state Current
Observed since 20 Oct, 18:17 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
168dev-react-paginate
A ReactJS component that creates a pagination.
A ReactJS component to render a pagination.
By installing this component and writing only a little bit of CSS you can obtain this: Note: You should write your own css to obtain this UI. This package do not provide any css.
or
Install 168dev-react-paginate with npm:
npm install 168dev-react-paginate --save
import React, { useEffect, useState } from 'react';
import ReactDOM from 'react-dom';
import ReactPaginate from '168dev-react-paginate';
// Example items, to simulate fetching from another resources.
const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
function Items({ currentItems }) {
return (
<>
{currentItems &&
currentItems.map((item) => (
<div>
<h3>Item #{item}</h3>
</div>
))}
</>
);
}
function PaginatedItems({ itemsPerPage }) {
// Here we use item offsets; we could also use page offsets
// following the API or data you're working with.
const [itemOffset, setItemOffset] = useState(0);
// Simulate fetching items from another resources.
// (This could be items from props; or items loaded in a local state
// from an API endpoint with useEffect and useState)
const endOffset = itemOffset + itemsPerPage;
console.log(`Loading items from ${itemOffset} to ${endOffset}`);
const currentItems = items.slice(itemOffset, endOffset);
const pageCount = Math.ceil(items.length / itemsPerPage);
// Invoke when user click to request another page.
const handlePageClick = (event) => {
const newOffset = (event.selected * itemsPerPage) % items.length;
console.log(
`User requested page number ${event.selected}, which is offset ${newOffset}`
);
setItemOffset(newOffset);
};
return (
<>
<Items currentItems={currentItems} />
<ReactPaginate
breakLabel="..."
nextLabel="next >"
onPageChange={handlePageClick}
pageRangeDisplayed={5}
pageCount={pageCount}
previousLabel="< previous"
renderOnZeroPageCount={null}
/>
</>
);
}
// Add a <div id="container"> to your HTML to see the component rendered.
ReactDOM.render(
<PaginatedItems itemsPerPage={4} />,
document.getElementById('container')
);
| Name | Type | Description |
|---|---|---|
pageCount | Number | Required. The total number of pages. |
pageRangeDisplayed | Number | The range of pages displayed. |
marginPagesDisplayed | Number | The number of pages to display for margins. |
previousLabel | Node | Label for the previous button. |
nextLabel | Node | Label for the next button. |
breakLabel | Node | Label for ellipsis. |
breakAriaLabels | Shape | Aria labels of ellipsis elements (Default are { forward: 'Jump forward', backward: 'Jump backward' }). |
breakClassName | String | The classname on tag li of the ellipsis element. |
breakLinkClassName | String | The classname on tag a of the ellipsis element. |
onPageChange | Function | The method to call when a page is changed. Exposes the current page object as an argument. |
onClick | Function | A callback for any click on the component. Exposes information on the part clicked (for eg. isNext for next control), the next expected page nextSelectedPage & others. Can return false to prevent any page change or a number to override the page to jump to. |
onPageActive | Function | The method to call when an active page is clicked. Exposes the active page object as an argument. |
initialPage | Number | The initial page selected, in uncontrolled mode. Do not use with forcePage at the same time. |
forcePage | Number | To override selected page with parent prop. Use this if you want to control the page from your app state. |
disableInitialCallback | boolean | Disable onPageChange callback with initial page. Default: false |
containerClassName | String | The classname of the pagination container. |
className | String | Same as containerClassName. For use with styled-components & other CSS-in-JS. |
pageClassName | String | The classname on tag li of each page element. |
pageLinkClassName | String | The classname on tag a of each page element. |
pageLabelBuilder | Function | Function to set the text on page links. Defaults to (page) => page |
activeClassName | String | The classname for the active page. It is concatenated to base class pageClassName. |
activeLinkClassName | String | The classname on the active tag a. It is concatenated to base class pageLinkClassName. |
previousClassName | String | The classname on tag li of the previous button. |
nextClassName | String | The classname on tag li of the next button. |
previousLinkClassName | String | The classname on tag a of the previous button. |
nextLinkClassName | String | The classname on tag a of the next button. |
disabledClassName | String | The classname for disabled previous and next buttons. |
disabledLinkClassName | String | The classname on tag a for disabled previous and next buttons. |
hrefBuilder | Function | The method is called to generate the href attribute value on tag a of each page element. |
hrefAllControls | Bool | By default the hrefBuilder add href only to active controls. Set this prop to true so href are generated on all controls (see). |
extraAriaContext | String | DEPRECATED: Extra context to add to the aria-label HTML attribute. |
ariaLabelBuilder | Function | The method is called to generate the aria-label attribute value on each page link |
eventListener | String | The event to listen onto before changing the selected page. Default is: onClick. |
renderOnZeroPageCount | Function | A render function called when pageCount is zero. Let the Previous / Next buttons be displayed by default (undefined). Display nothing when null is provided. |
prevRel | String | The rel property on the a tag for the prev page control. Default value prev. Set to null to disable. |
nextRel | String | The rel propery on the a tag for the next page control. Default value next. Set to null to disable. |
prevPageRel | String | The rel property on the a tag just before the selected page. Default value prev. Set to null to disable. |
selectedPageRel | String | The rel propery on the a tag for the selected page. Default value canonical. Set to null to disable. |
nextPageRel | String | The rel property on the a tag just after the selected page. Default value next. Set to null to disable. |
See CONTRIBUTE.md
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
prop-typesEnvironment{
"local_name": "prop-types",
"alias": false,
"peer_metadata": null
} | ^15 | runtime |
huskyEnvironment{
"local_name": "husky",
"alias": false,
"peer_metadata": null
} | ^9 | development |
reactEnvironment{
"local_name": "react",
"alias": false,
"peer_metadata": null
} | ^19 | development |
eslintEnvironment{
"local_name": "eslint",
"alias": false,
"peer_metadata": null
} | ^9 | development |
jqueryEnvironment{
"local_name": "jquery",
"alias": false,
"peer_metadata": null
} | ^3.7 | development |
core-jsEnvironment{
"local_name": "core-js",
"alias": false,
"peer_metadata": null
} | ^3 | development |
expressEnvironment{
"local_name": "express",
"alias": false,
"peer_metadata": null
} | ^4 | development |
webpackEnvironment{
"local_name": "webpack",
"alias": false,
"peer_metadata": null
} | ^5 | development |
jest-cliEnvironment{
"local_name": "jest-cli",
"alias": false,
"peer_metadata": null
} | ^29 | development |
prettierEnvironment{
"local_name": "prettier",
"alias": false,
"peer_metadata": null
} | ^3.4 | development |
react-domEnvironment{
"local_name": "react-dom",
"alias": false,
"peer_metadata": null
} | ^19 | development |
@babel/coreEnvironment{
"local_name": "@babel/core",
"alias": false,
"peer_metadata": null
} | ^7 | development |
webpack-cliEnvironment{
"local_name": "webpack-cli",
"alias": false,
"peer_metadata": null
} | ^6 | development |
babel-loaderEnvironment{
"local_name": "babel-loader",
"alias": false,
"peer_metadata": null
} | ^9 | development |
serve-staticEnvironment{
"local_name": "serve-static",
"alias": false,
"peer_metadata": null
} | ^1 | development |
react-refreshEnvironment{
"local_name": "react-refresh",
"alias": false,
"peer_metadata": null
} | ^0.16.0 | development |
@babel/preset-envEnvironment{
"local_name": "@babel/preset-env",
"alias": false,
"peer_metadata": null
} | ^7 | development |
styled-componentsEnvironment{
"local_name": "styled-components",
"alias": false,
"peer_metadata": null
} | ^6 | development |
@babel/preset-reactEnvironment{
"local_name": "@babel/preset-react",
"alias": false,
"peer_metadata": null
} | ^7 | development |
eslint-plugin-reactEnvironment{
"local_name": "eslint-plugin-react",
"alias": false,
"peer_metadata": null
} | ^7 | development |
@babel/eslint-parserEnvironment{
"local_name": "@babel/eslint-parser",
"alias": false,
"peer_metadata": null
} | ^7 | development |
@testing-library/reactEnvironment{
"local_name": "@testing-library/react",
"alias": false,
"peer_metadata": null
} | ^16 | development |
jest-environment-jsdomEnvironment{
"local_name": "jest-environment-jsdom",
"alias": false,
"peer_metadata": null
} | ^29.7.0 | development |
webpack-dev-middlewareEnvironment{
"local_name": "webpack-dev-middleware",
"alias": false,
"peer_metadata": null
} | ^7 | development |
webpack-hot-middlewareEnvironment{
"local_name": "webpack-hot-middleware",
"alias": false,
"peer_metadata": null
} | ^2.26.1 | development |
@pmmmwh/react-refresh-webpack-pluginEnvironment{
"local_name": "@pmmmwh/react-refresh-webpack-plugin",
"alias": false,
"peer_metadata": null
} | ^0.5.15 | development |
reactEnvironment{
"local_name": "react",
"alias": false,
"peer_metadata": null
} | ^16 || ^17 || ^18 || ^19 | peer |
Source distribution
{
"shasum": "952acdb34b617abb0fbe14afa45e2b571fb1daaa",
"tarball": "https://registry.npmjs.org/168dev-react-paginate/-/168dev-react-paginate-8.2.0.tgz",
"fileCount": 15,
"integrity": "sha512-QPFOyMWoZaAYRV7A7erncnLiasM5aLzVYlAWPYqRRTl2hOVpfFNdrsWlw4MVeeXNk5Jn3WnSlN/gw0BwOaNZJQ==",
"signatures": [
{
"sig": "MEUCIQCZpUyEdppGOU8tyIKFGzn1hdJD2cXW7PwcZgyrq8/UyQIgK0nqprP5XDMRf/nbBgtqf/nrwSE456to0P6KHCRshDU=",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 122389
}Shared repository data · GitHub
Observed since 20 Oct, 18:17 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:5ca511d6c5b46ae7f8e75f2cde52fe4700bda8aa3d166e54fab60434c8aef636