Skip to content

Instantly share code, notes, and snippets.

@sakukode
Last active November 5, 2019 01:13
Show Gist options
  • Save sakukode/18a7ac5c67e14857c7fca48f1f2d2d4f to your computer and use it in GitHub Desktop.
Save sakukode/18a7ac5c67e14857c7fca48f1f2d2d4f to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
const TableHeader = () => {
return (
<thead>
<tr>
<th>Nama</th>
<th>Pekerjaan</th>
</tr>
</thead>
)
}
const TableBody = props => {
const rows = props.characterData.map(row, index) => {
return (
<tr key={index}>
<td>{row.name}</td>
<td>{row.job}</td>
</tr>
)
})
return (
<tbody>{rows}</tbody>
)
}
class Table extends Component {
render() {
const { characterData } = this.props
return (
<table>
<TableHeader />
<TableBody characterData={characterData} />
</table>
)
}
}
export default Table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment