1.0.8 • Published 5 years ago

react-recycled-scrolling v1.0.8

Weekly downloads
129
License
MIT
Repository
github
Last release
5 years ago

React Recycled Scrolling

npm Build Status Coverage Status

Simulate normal scrolling by using only fixed number of DOM elements for large lists of items with React Hooks

Install

npm install --save react-recycled-scrolling

Usage

All that is required is

  • attrList: A list of items
  • itemFn: A React functional component or even just a function that returns jsx for each element
const numberList = []
for (let i = 1; i <= 20000; i++) numberList.push(i)
const SheepRow = (no) => (<div> {no} Sheep </div>)

Then just drop in your RecycledList wherever you need it

import RecycledList from 'react-recycled-scrolling'

<RecycledList
itemFn = {SheepRow}
attrList = {numberList}
/>

Additional parameters are

  • itemHeight: Height of each item, Default: 50
  • rowOffset: How many buffer rows you need outside the viewable screen, Default: 6
  • className: custom CSS for the outer scroll wrapper. You must have {position: relative} for recycled scroll to work
<RecycledList
  itemFn = {SheepRow}
  attrList = {numberList}
  itemHeight = {120}
  rowOffset = {10}
  className = {'CustomContainer'}
/>

Example

Edit jovial-haibt-y8mlf

https://codesandbox.io/s/jovial-haibt-y8mlf?fontsize=14

License

MIT

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago