Skip to content

Instantly share code, notes, and snippets.

@iammdmusa
Last active September 17, 2019 11:54
Show Gist options
  • Save iammdmusa/754993070519a5c0fdd0794d770e4e41 to your computer and use it in GitHub Desktop.
Save iammdmusa/754993070519a5c0fdd0794d770e4e41 to your computer and use it in GitHub Desktop.
Class List extends Component {
state = {
data : []
}
// use this on your API response section only
this.setState({
data : response.data // this will be you receiving data in array path
})
render() {
const { data } = this.state
return(
<table>
<tr>
<th>Id</th>
<th>Name</th>
<th>Mobile</th>
<th>Photo</th>
</tr>
{data && data.map(rowData => (
<tr key={rowData.id}>
<td>{rowData.id}</td>
<td>{rowData.name}</td>
<td>{rowData.mobile}</td>
<td>{rowData.photo}</td>
</tr>
)}
</table>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment