interface State {
detailsItem: Array<{
id: string;
name: string;
designation: string;
}>;
interface Props{
id: string;
name: string;
desgination:string
}
Method:
sampleItem = () => {
this.sampleService
.sampleMethod(this.props.id, this.props.name, this.props.designation)
.then((response) => {})
.catch((error) => {
console.log(error);
});
};
I want to replace props and i want to fetch id,name & designation from the array of detailsItem.In the below method, I am trying doing that, but getting an error
sampleItemOne = () => {
this.state.detailsItem.map((item) => {
{ item? (
this.sampleService
.sampleMethod(item.id, item.name, item.designation)
.then((response) => {})
.catch((error) => {
console.log(error);
})
: null;
}
});
};
I tried removing the props & calling the id, name & designation in sampleItemOne but getting an error: Expected an assignment or function call and instead saw an expression Can anyone please help me with this, what I am doing wrong!