@jswork/react-chunk-list
v1.1.1
Published
List with time chunk for react.
Readme
react-chunk-list
List with time chunk for react.
installation
npm install -S @jswork/react-chunk-listproperties
| 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
- 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: ()- 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
- https://afeiship.github.io/react-chunk-list/
license
Code released under the MIT license.
