App.jsPreformatted text
function App() {
const contacts = [ {
"id": "1",
"name": "Affi phuck",
"email": "phucksheikh111@gmail.com"
},
{
"id": "2",
"name": "Usman Bazmi",
"email": "bazmi69@hotmail.com"
},
{
"id": "3",
"name": "Jawad",
"email": "Jojo111@gmail.com"
},
{
"id":"4",
"name":"fadi",
"email":"fadi21@gmail.com"
}]
return (
<div className="App">
<DisplayList contacts={contacts}/>
</div>
);
}
export default App;
displayList.js
import React from 'react';
function displayList(props) {
const renderList = props.contacts.map((contact)=>{
return (
<div>
<div className="card" style={{width:"70%"}}>
<div className="card-header" >
<h3>Contact List</h3>
</div>
</div>
<div className="card-body" style={{width:"70%"}}>
<table className="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Email</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<th>{contact.id}</th>
<td>{contact.name}</td>
<td>{contact.email}</td>
<td>
<button className="btn btn-outline-primary" style={{marginRight:"7px"}}><i class="bi bi-pencil-square"></i></button>
<button className="btn btn-outline-danger"><i className="bi bi-trash-fill"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
);
});
return(
<div>
{renderList}
</div>
)
}
Output: