0.0.2 • Published 5 years ago

react-sorted-table v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

sorted-table

A simple sortable table component.

NPM JavaScript Style Guide

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

0.0.2

5 years ago

0.0.1

5 years ago