1.0.2 • Published 6 years ago

@clinyong/react-scroll-list v1.0.2

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

A react component to render large lists. Inspired by react-virtualized, but much simpler.

Install

$ npm install @clinyong/react-scroll-list --save

Usage

import { ScrollList } from "@clinyong/react-scroll-list";

class LargeList extends React.Component {
  constructor() {
    this.state = {
      list: [1, 2, 3]
    };
  }

  rowRenderer = ({ index, style }) => {
    const item = this.state.list[index];

    return (
      <li key={item} style={style}>
        {item}
      </li>
    );
  };

  render() {
    return (
      <ul>
        <ScrollList
          height={250}
          rowHeight={32}
          total={this.state.list.length}
          rowRenderer={this.rowRenderer}
        />
      </ul>
    );
  }
}