🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

react-paginated-list

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-paginated-list

A simple react component to render a paginated list ✨powered by styled-components 💅

latest
Source
npmnpm
Version
1.1.6
Version published
Weekly downloads
119
17.82%
Maintainers
1
Weekly downloads
 
Created
Source

React Paginated List

npm npm NPM

A simple react component to render a paginated list ✨powered by styled-components 💅

DEMO

React Paginated List working

Installation

Using npm

npm install react-paginated-list

Or yarn

yarn install react-paginated-list

Usage

  • Pass in the list items that contain your data in the list prop
  • In the renderList prop, pass in the function to render out the list.
let users = [{'a': 123, 'b': 345}, {'c': 678, 'd': 891}];
return (
<PaginatedList
    list={users}
    itemsPerPage={3}
    renderList={(list) => (
      <>
        {list.map((item, id) => {
          return (
            <div key={id}>
              {item.a} {item.b}
            </div>
          );
        })}
      </>
    )}
  />);

Example Project

To run the example project,

  • Clone the repo
git clone https://github.com/rigelglen/react-paginated-list
  • Install deps
npm run install-all
  • Run example project
npm run dev

Props

* indicates a required prop

PropDescriptionTypeDefault
list*This is the list of items managed by the component.
This list will be available in the renderList method to render your list
Array-
renderList*This is the function that renders each of your list items.(list: Array) => JSX.Element-
itemsPerPageNumber of items per pagenumber10
onPageChangeCallback function that is called when the page is changed(items: Array, currentPage: number) => void-
isLoadingSets whether the list is loading or not.booleanfalse
ControlItemStyled Component for the pagination itemAnyStyledComponentstyled.li`
ControlContainerStyled Component for the pagination controlsAnyStyledComponentstyled.div``
PaginatedListContainerStyled Component for the entire paginated list (contains the actual list and pagination controls)AnyStyledComponentstyled.div``
loadingItemComponent to be displayed when list is loadingJSX.Element<p>Loading...</p>
breakTextText to be shown for ellipsisstring'...'
displayRangeThe range of pages displayednumber3
leftMarginNumber of extra pagination items to display on the leftnumber1
rightMarginNumber of extra pagination items to display on the rightnumber1
currentPageSets the initial pagenumber1
controlClassClass of the pagination boxstring'pagination'
activeControlClassClass of the active pagination itemstring'active'
displayNumbersDisplay pagination numbersbooleantrue
loopAroundLoop around after the endbooleanfalse
breakClassClass for the break itemstring'pagination-break'
nextClassClass of the next buttonstringnext
prevClassClass of the prev buttonstringprev
paginatedListContainerClassClass of the entire paginated list (contains the actual list and pagination controls)string-
controlItemClassClass of every pagination control itemstringpagination-item
showPrevShow previous pagination control (does nothing if useMinimalControls is true)booleantrue
showNextShow next pagination control (does nothing if useMinimalControls is true)booleantrue
nextTextText inside next buttonstring'〉'
prevTextText inside prev buttonstring'〈'
useMinimalControlsHides next or previous button if there is no next or previous page respectively.booleanfalse

LICENSE

Released under the MIT license. MIT: http://rem.mit-license.org, See LICENSE

Keywords

react-component

FAQs

Package last updated on 26 May 2022

Did you know?

Socket

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.

Install

Related posts