paginated-list
v2.0.8
Published
Add pagination to a list of React components
Downloads
8
Readme
paginated-list
Add pagination to a list of React components
Install
npm install --save paginated-list
Usage
import React from 'react';
import PropTypes from 'prop-types';
import withPaginatedList from 'paginated-list';
const Element = ({ item }) => {
return (
<span>{item}</span>
);
};
Element.propTypes = {
item: PropTypes.string.isRequired
};
const App = () => {
const elements = ['Test1', 'Test2', 'Test3', 'Test4', 'Test5', 'Test6', 'Test7', 'Test8'];
const PaginatedList = withPaginatedList(Element, (offset, limit) => {
return new Promise((resolve, reject) => {
resolve({
items: elements.slice(offset, offset + limit),
totNumItems: elements.length
});
});
}, 2, 5, true);
return (
<div>
<PaginatedList />
</div>
);
};
export default App;
License
MIT © valearna