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. array the form looks like this The array looks like this and the data on my page looks like this. The functionality I want is if I click on any entry it deletes one entry only and refreshes with the remaining three entries. If I click one the other entries two three and four should be visible and one deleted
Currently, if I click on one entry to delete it deletes both entries from the current searched index if the id matches.
const [standup, setStandup] = useState({
yesterday: {
entry:"",
id:""
},
today: {
entry:"",
id:""
}
});
const [allStandups, setAllStandups] = useState([]);
checked here to delete only entries from yesterday but it is deleting the whole index both entries inside the id.
function deleteItem(id) {
setAllStandups((prevStandup)=>{
return prevStandup.filter((standup) => {
return (standup.yesterday.id !== id;
});
})
}