I have an array of objects. The object contains two enteries I want to delete one entry and refresh the page with only one entry loading on the page.
CodePudding user response:
`function deleteItem(id) { setAllStandups((prevStandup)=>{
return prevStandup.map((standup) => {
if(standup.yesterday.id === id){
return {...standup.today}
}
else{
return {...standup.yesterday};
}
});
})
}`
this will delete only clicked value.
CodePudding user response:
It is not array, It should be deleting the node from JSON Object.
function deleteItem(NodeName,precStandup) {
delete precStandup[NodeName];
return precStandup;
}
let result=deleteItem("yesterday",standup);