so initially in image 1 i have this function dispatch, when it gets called it passes two argument "type" and "item".
Now the problem is, in image 2 i need to return the item to state object and store it in that state and every time that dispatch function gets called new values of item should be added to state but but......the state object is not retaining the item value, it is removing the previous value and passing the new value so i am receiving only the last value.
I need to map that item property later and for that i need it to be an array, so it should be like:
const state = {
count: 1,
item: [product1, product2, product3, ......]
}
Note: product is an object
It should be something like
return {
...state,
count : state.count + 1,
item : [...state.item, action.item]
}