Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@CITGuru
Created July 26, 2019 09:57
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 CITGuru/1fe5e2824c6538dc01e4d4a64967d214 to your computer and use it in GitHub Desktop.
Save CITGuru/1fe5e2824c6538dc01e4d4a64967d214 to your computer and use it in GitHub Desktop.
import React from 'react'
import PropTypes from 'prop-types'
function UserTable(props) {
const { data, setSelected, setModalState } = props
return (
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Job Title/th>
<th>Action</th>
<th />
</tr>
</thead>
<tbody>
{data.map(row => {
const { id, name, age, job_title } = row
return (
<tr key={id}>
<td>{name}</td>
<td>{age}</td>
<td>{job_title }</td>
<td>
<button
onClick={() => {
setSelected(row)
setModalState(true)
}}
>
View
</button>
</td>
</tr>
)
})}
</tbody>
</table>
)
}
UserTable.propTypes = {
data: PropTypes.array,
setSelected: PropTypes.func.isRequired,
setModalState: PropTypes.func.isRequired
}
export default UserTable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment