Skip to content

Instantly share code, notes, and snippets.

@agamdua
Created March 18, 2017 19:03
Show Gist options
  • Save agamdua/180807cf15caf5fa24a1660b5559f780 to your computer and use it in GitHub Desktop.
Save agamdua/180807cf15caf5fa24a1660b5559f780 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import ReactTable from 'react-table'
import './App.css';
import 'react-table/react-table.css'
const data = [{
name: 'Tanner Linsley',
age: 26,
friend: {
name: 'Jason Maurer',
age: 23,
}
}]
const columns = [{
header: 'Name',
accessor: 'name' // String-based value accessors!
}, {
header: 'Age',
accessor: 'age',
render: props => <span className='number'>{props.value}</span> // Custom cell components!
}, {
header: 'Friend Name',
accessor: d => d.friend.name // Custom value accessors!
}, {
header: props => <span>Friend Age</span>, // Custom header components!
accessor: 'friend.age'
}]
class App extends Component {
render() {
return (
<div className="App">
<ReactTable
data={data}
columns={columns}
/>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment