reducer in redux performs a minus one operation
export default (state = initialState, action) => {
const {total} = state
switch(action.type){
case ActionTypes.ADD:
//
return {...state, total: total + 1}
case ActionTypes.SUBTRACT:
//
return {...state, total: total - 1}
default:
return state
}
}
what is the difference between return {.state, total: total-1}
and return state
returned by default? what is the role of
.state