In my react app I create a store and reducer using redux.
And I have one state name as "cart" which is an object array.
And I want to remove and an element which I pass the id as a payload in reducer case only.
How can I remove an element from this state which is id equal to payload ID?
This is cart state structure
const reducer = (state = initialState, action) => {
case actionTypes.QUANTITY_COUNT:
const newCart = {...state.cart};
if (newCart[action.id].quantity === 1){
//here i want to remove element from cart/newCart of Id as action.id
}
}