1.4.0 • Published 1 year ago

react-dynamic-virtual-scroll v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-dynamic-virtual-scroll

React component available to implement virtual-scroll at any page without worrying about the dynamic item height.

You can play with the library over here: Codesandbox

Installation

npm install react-dynamic-virtual-scroll

No external dependencies so no need to worry about security and package size.

Usage

  • Import component.

    import VirtualScroll from "react-dynamic-virtual-scroll";
  • Add component as follows in your render method:

    <VirtualScroll
        className="List"
        minItemHeight={40}
        totalLength={100}
        renderItem={(rowIndex) => {
            return (
              <div className="List-item">
                <h3>List item: {rowIndex}</h3>
              </div>
            );
        }}
    />

Props Table

nametyperequireddefaultdescription
minItemHeightnumbertrueMinimum item height to calculate the placeholder spacing.
totalLengthnumbertrueTotal number of items to be rendered.
renderItem(rowIndex) => React.ReactNodetrueCallback to render items for specified index values. 0-indexed
lengthnumber30Total number of items to be rendered in the dom.
buffernumber10Total number of items to be rendered in the dom before and after your required dom items.