- 1
I have a doubt in the question given below from the react +redux course
Multiple Reducers Fill in the blanks to create a valid reducer function: _______reducer(state, action) { _________(action.type) { _______'ADD_ITEM': return [ ...state, action.item ] _____: _______ state } }
3 Answers
+ 4
It's reducer function with switch statement.
Correct Answer:
function reducer(state, action) {  
   switch(action.type) {
      case 'ADD_ITEM':
        return [...state, action.item]
      default:
        return state
  }
}
+ 4
Ultimate answer:
function toggle(status) {
 return { 
type
: 'TOGGLE', data: status } 
}
function reducer(state, action) {
  switch(action.
type
) {
    
case
 'TOGGLE':
      return { status: state.status+action.data };
    default:
      
return
 state;
  }
}
0
function
switch
case
default
return



