0.0.2 • Published 5 years ago
react-sorted-table v0.0.2
sorted-table
A simple sortable table component.
Install
npm install --save react-sorted-table
# or
yarn add react-sorted-table
Usage
import React from 'react'
import SortedTable from 'react-sorted-table'
import moment from 'moment'
const columns = [
{ id: 'name', label: 'Name', accessor: 'name' },
{ id: 'date', label: 'Date', accessor: item => moment(item.date).format('YYYY/MM/DD') },
{ id: 'quantity', label: 'Quantity', accessor: 'quantity' },
{ id: 'reference', label: 'Reference', accessor: 'reference' },
]
const data = [
{ _id: '0001', name: 'tomato', date: new Date(), quantity: 55, reference: '#AF34' },
// ...
]
const Example = () => (
<div>
<SortedTable columns={columns} data={data} keyAccessor='_id' />
</div>
)
License
MIT © hissalht