Skip to content

Instantly share code, notes, and snippets.

@selbekk
Last active March 17, 2017 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selbekk/8a92c92138b36331fac5b942d5f4e0fc to your computer and use it in GitHub Desktop.
Save selbekk/8a92c92138b36331fac5b942d5f4e0fc to your computer and use it in GitHub Desktop.
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