This is the state of the gearbox. I need to add, update, delete an object in cartData. For the first time, cartData is empty.
const initialState = {
   fetchData: {},
   cartData: {}
}
Example:
fetchData: {
  "React":{'name': 'React'},
  "Node":{'name': 'Node'},
}
If the user ADD_ITEMresponds to the book, a new element is added here.
cartData:{
  "React":{'name': 'React', 'quantity': 1}, 
}
If the user Edit_ITEMresponds to the book, the existing item is updated here.
cartData:{
  "React":{'name': 'React', 'quantity': 4}, 
}
If the user REMOVE_ITEMresponds to the book, deleting it when it reaches zero here.
cartData:{
}
How can we change the state of reduction for these actions?
Tried this: using lodash. But it didnβt work out right.
case types.ADD_ITEM:
   return { ...state, cartData: 
case types.EDIT_ITEM:
   return { ...state, [state.cartData.name]: action.payload  }
case types.REMOVE_ITEM:
   return _.omit(state, [state.cartData.name]: action.payload)