I am trying to delete an item in a nested state but I have no idea how to implement that.
data structure
{
property: {
"_id" : "52",
"name" : "random",
"options" : ["item1", "item2", "item3"]
}
}
to delete a property, I am just making a comparison like this and it is working
property: state.property.filter(data => data._id !== action.propertyId),
but the problem is when I want to delete an item of options array, how can I delete an item and compare the values
Maybe you're looking for below...
let state = {
"property": {
"_id": "52",
"name": "random",
"options": ["item1", "item2", "item3"]
}
}
state.property.options = state.property.options.filter(ele => ele !== "item2")
console.log(state)