I am using Angular 2+ with Redux and is fine, but can not modify quantity with the new value
The error is: TypeError: Cannot assign to read only property 'quantity' of object '[object Object]'
export interface CartState {
readonly cars: CartCarModel[]
}
export class CartCarModel {
constructor (
public carId: string,
public carModel: string,
public quantity: number,
public price: number) { }
}
const initialState: CartState = {
cars: []
}
function reducerFunc (state: CartState, id: string, quantity: number) {
const nextState = produce(state, draft => {
draft.cars.find(d => d.carId === id).quantity = quantity
})
return Object.assign({}, state, {
drinks: nextState
})
}