Created
March 18, 2017 19:03
-
-
Save agamdua/180807cf15caf5fa24a1660b5559f780 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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