@jswork/react-chunk-list

1.1.1 • Public • Published

react-chunk-list

List with time chunk for react.

version license size download

installation

npm install -S @jswork/react-chunk-list

properties

Name Type Required Default Description
className string false - The extended className for component.
items array false [] List data source.
template func false noop List item template.
interval number false 100 The timer duration.
chunk number false 5 The chunk size.

usage

  1. import css
@import "~@jswork/react-chunk-list/dist/style.css";

// or use sass
@import "~@jswork/react-chunk-list/dist/style.scss";

// customize your styles:
$react-chunk-list-options: ()
  1. import js
import ReactDemokit from '@jswork/react-demokit';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactChunkList from '@jswork/react-chunk-list';
import './assets/style.scss';

class App extends React.Component {
  state = { hasUpdate: false, items: [] };
  componentDidMount() {
    this.genList();
  }

  genList() {
    const items = [];
    for (let index = 0; index < 4000; index++) {
      items.push({
        id: index,
        value: `value - ${index}`
      });
    }
    console.time('render');
    this.setState({ items });
  }

  componentDidUpdate() {
    console.timeEnd('render');
  }

  render() {
    return (
      <ReactDemokit
        className="p-3 app-container"
        url="https://github.com/afeiship/react-chunk-list">
        <ReactChunkList
          items={this.state.items}
          interval={10}
          chunk={1000}
          template={({ item }) => {
            return <div key={item.id}>{item.value}</div>;
          }}
          className="bg-gray-800 mb-5 p-4 text-white"
        />
      </ReactDemokit>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('app'));

documentation

license

Code released under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i @jswork/react-chunk-list

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

22.4 kB

Total Files

7

Last publish

Collaborators

  • afeiship