You are mutating the state directly. In a general scenario in Redux you must ... operator
. Something like this:
For
orderedItems: [
{item:"1Reco",price:"12",amount:1},
{item:"2Reco",price:"12",amount:1},
],
Try
const updatedOrderedItems = orderedItems.map(obj=>{
if(obj.item==="2Reco"){
obj.amount=obj.amount+1;
return obj;
}
return obj;
});
Now your updatedOrderedItems contains the updated array of object containing the amount 2 for second object.
Then you can update global state in redux from your reducer function as follows:
return{
...state,
orderedItems: updatedOrderedItems
fullPrice: 0,
windowWidth: 1418,
language: "en"
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…