I’m new to redux,My problem is when i dispatch action, it is going to the reducer but the state is not updating.
This is my initial state
const initialState ={
cart :[ ],
Products:[
{
id:"1",
title:"Realme 3 pro",
image:{
img1:"https://www.monotain.com/wp-content/uploads/2019/12/realme-5-pro.jpg",
img2:"https://static.techspot.com/images/products/2019/smartphones/org/2019-05-20-product-7.jpg"
},
price:"10000",
details:"Take photography a notch higher with the Realme 3 Pro as it comes with a 25 MP AI Selfie Camera and 16 MP + 5 MP Rear Camera with Sony IMX519 Sensor. The Qualcomm Snapdragon 710 AIE, multi-core AI Engine and Adreno 616 GPU redefine your smartphone experience.",
seller:"Cloudtail India",
quantity:"0"
}
]
}
** This is my reducer which is handling this action **
case UPDATE_QUANTITY:
return{
...state,
cart:state.cart.map((product,i) =>
{
if(i === (action.product.id-1))
{
product.quantity = action.qty.toString();
}
})
}
Other reducers are working fine and returning correct state but when i dispatch this action,My state is not updating .If there is any improvement to be done on code .Please specify