State Management · Junior · Question 9 of 75

What does useReducer return?

const [state, dispatch] = useReducer(reducer, initialState);

Explanation

You call dispatch({ type: 'added', text }), React calls reducer(state, action) and uses the returned value as the next state. dispatch is stable across renders, so it's safe to pass down and to use in effect dependencies.

Further reading

Problem with a question

State Management · Junior · question 9

Test yourself

Take the State Management · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz