I was trying to add an state which suppose to have a array of indexes and each of these index must compare with state index and delete of store state, for example I have a product's state:
state.products = [
{productName: "patric", withTax: "0.57", noTax: "2.30", tax: 25, quantity: 2}
{productName: "parafuso", withTax: "55.50", noTax: "222.00", tax: 25, quantity: 2} //remove this
{productName: "mamao", withTax: "0.57", noTax: "2.30", tax: 25, quantity: 5} // remove this
]
action.index = [
{productName: "parafuso", withTax: "55.50", noTax: "222.00", tax: 25, quantity: 2} //remove this
{productName: "mamao", withTax: "0.57", noTax: "2.30", tax: 25, quantity: 5} // remove this
]
//this is not removing the selecteds items
const products = state.products.filter((product, i) => {
for(let i=0; i < action.index.length; i++){
if(product.name !== action.index[i].name) return true
}
return false
})
return {
...state,
products
}