Reducer using action creator

This is a question using this problem as an example. The reducer is using action.todo. todo is not being called as a function like action.todo() but seems to be used as a property. There doesn’t seem to be a defining of todo on action. How is the reducer using the addTodo action creator?

const immutableReducer = (state = ['Do not mutate state!'], action) => {
  switch(action.type) {
    case 'ADD_TO_DO':
      // Don't mutate state here or the tests will fail
      return [...state, action.todo];
      return state;

const addToDo = (todo) => {
  return {
    type: 'ADD_TO_DO',

const store = Redux.createStore(immutableReducer);

Happily or embarrassingly, answers come just after questions. This might be the right idea.
The action creator describes the case of the action type being “ADD_TO_DO” and defines the action as updating type with a todo.
In the case that the type is “ADD_TO_DO” the new state is the old state amended with the values described in addToDo. todo is some added task such as “Finalize draft.”

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.