我正在创建一个应该允许教师向其仪表板添加课程的应用程序,只是课程名称没有保存到商店。
export const addCourse = (name, instructor) => {
return function(dispatch) {
axios.post(`http://localhost:3001/api/courses`, {
name: name,
_creator: instructor
})
.then(response => {
cookies.get('instructor', response.data.instructor)
dispatch({
type: ADD_COURSE,
coursename: name,
_creator: cookies.get('instructor')
})
console.log(response.data)
})
}
}

和减速器低于
const INITIAL_STATE = {
coursename: [''],
_creator: [{}]
}
export default function(state = INITIAL_STATE, action) {
switch(action.type) {
case ADD_COURSE:
return {...state,
coursename: [...state.coursename, action.coursename],
_creator: action._creator
}
}
return state;
}

我错过了用户的输入无法保存到商店的内容?