1.

Show with an example how reducers are used in Redux.

Answer»

An EXAMPLE of how reducers are USED in Redux is GIVEN below:

CONST initial_state = { value: 0 }function countReducer(state = initial_state, action) { // Checking to see if the REDUCER cares about this action if (action.type === 'counter/incremented') { // If the action is of type "counter" or "incremented", we make a copy of `state` return { ...state, // We also update the copy with the new value value: state.value + 1 } } // If not, we return the original state unchanged return state}


Discussion

No Comment Found