Last active
March 17, 2017 10:37
-
-
Save selbekk/8a92c92138b36331fac5b942d5f4e0fc 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
const Table = props => ( | |
<table> | |
<thead> | |
<tr> | |
{props.headers.map(header => <th>{header}</th>)} | |
</tr> | |
</thead> | |
<tbody> | |
{props.data.map(row => ( | |
<tr> | |
{row.map((column, colIndex) => ( | |
<td data-th={props.headers[colIndex]}>{column}</td> | |
))} | |
</tr> | |
))} | |
</tbody> | |
</table> | |
); | |
const headers = ['Name', <div><Icon /> Address</div>, 'Age']; | |
const data = [ | |
['Eric', 'Street 1', 18], | |
['Erica', 'Street 2', 28], | |
]; | |
ReactDOM.render(<Table headers={headers} data={data} />, someEl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment