React Output Prediction Hard +35 XP
useReducer Action
What is the state after dispatching this action?
ReactRead-only
const reducer = (state, action) => {
switch(action.type) {
case "INCREMENT": return { count: state.count + 1 };
default: return state;
}
};
// state = { count: 5 }, dispatch({ type: "INCREMENT" })What is the output?
Show answer and explanation
Answer: { count: 6 }
The INCREMENT case returns a new state object with count incremented by 1. 5 + 1 = 6.
Hint: INCREMENT adds 1 to the current count.
What this challenge tests
Output Prediction in React: useReducer, state.