Reusable react data table component
npm install react-fun-table##### Check out the example.
``js` columns={columns}
data={data}
sortBy={columns[0].attribute
/>

By default sorting is done by the first column, ascending. You can click on a column header to sort by that column. Right now, sorting is only by string and doesn't work with numbers properly. TODO: // add integer / double sorting.
__npm__
`bash`
npm i react-fun-table styled-components --save
__yarn__
`bash`
yarn add react-fun-table styled-components
Use react-fun-table as below.
`js
import React from 'react'
import { Table } from 'react-fun-table'
const data = [
{
"field_name": "Potatoes",
"area_in_hectares": 0.3,
"active": false,
"company_name": "Potato Company",
"cultivation_id": 1,
"crop_name": "Potatoes",
"harvest_year": 2017
},
{
"field_name": "Shrimp",
"area_in_hectares": 1,
"active": true,
"company_name": "Shrimpcorp",
"cultivation_id": 3,
"crop_name": "Shrimp",
"harvest_year": 2016
},
// ...
];
const columns = [
{
"attribute": "field_name",
"label": "Name",
},
{
"attribute": "cultivation_id",
"label": "Nummer",
},
{
"attribute": "company_name",
"label": "Betrieb"
},
{
"attribute": "area_in_hectares",
"label": "Fläche"
},
{
"attribute": "active",
"label": "Aktiv"
},
{
"attribute": "crop_name",
"label": "Kultur"
},
{
"attribute": "harvest_year",
"label": "Ernte"
}
];
const App = () => (
``