Created
July 26, 2019 09:57
-
-
Save CITGuru/1fe5e2824c6538dc01e4d4a64967d214 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 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