I have an array called products and inside of that I have a field called productCategory. My problem is that its clearing up other values of the array.
Codesandboxis here CLICK HERE
case appConstants.CHANGE_PRODUCT_CATEGORY:
return {
...state,
products: state.products.map((product) => {
product?.productCode === action.payload?.productCode
? {
...product,
productCategory: action.payload.productCategory
}
: product;
})
};