Learning React Redux and am a newbie so sorry in advance if this is a dumb question. I am currently trying to work throguh some example code and have the following in two separate slices:
Reducer in slice 1:
incrementQuantity: (state, action) => {
const { payload: index } = action;
if (state[index]) {
if (state[index].name === " Auditorium Hall (Capacity:200)" && state[index].quantity >= 3) {
return; }
state[index].quantity++;
}
Reducer in slice 2:
toggleMealSelection: (state, action) => {
state[action.payload].selected = !state[action.payload].selected;
},
Just don’t understand the usage of payload/action in both of the above. Can someone explain whats going on with the two different lines i.e.
const { payload: index } = action;
and
state[action.payload].selected = !state[action.payload].selected;
In simple terms
Nothing to try, just want a simple explanation
Thomas Cherian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.