The reducer function in useReducer is called only when the dispatch function is used to update the state.