const Company = props => (
<tr>
<td>{props.company.companyName}</td>
<td>{props.company.taxOffice}</td>
<td>{props.company.taxNumber}</td>
<td>{props.company.date}</td>
<td>
<Button variant="danger" onClick={()=>handleDelete(props)}>Delete</Button>
</td>
<td>
<Button variant="success" onClick={()=>handleEdit(props)}>Edit</Button>
</td>
</tr>
);
Определите функцию handleDelete
, откуда вы передаете данные в Company
компонент
handleDelete=(data)=>{
// make api request to delete object by(data.id)
}
handleEdit=(data)=>{
//make your model show to true
// then set your data fiels to state.
// then make your model show to false after updation
}
, передайте handleDelete
и handleEdit
в Company
компонент
companyList() {
return this.state.companies.map(currentcompany => {
return <Company handleDelete={this.handleDelete}
company={currentcompany} key={currentcompany._id}
handleEdit={this.handleEdit}/>;
});
}