TypeError:Object(...)不是函数 模块../src/redux/store.js C:/用户/我的电脑/桌面/项目/反应/2020_03_29_workshop/src/redux/store.js:13
13 |导出默认的createStore(rootReducers,composeWithDevtools(applyMiddleware(thunk)))
reducers.js
import { GET_ALL_POSTS, GET_ALL_SPECIALITIES, GET_ALL_COURSES, GET_ALL_TEACHERS,
GET_POST, GET_SPECIALITY, GET_LESSON, GET_COURSE } from "./actions"
export const postReducer = (state = {}, action) => {
if(action.type === GET_ALL_POSTS){
return {
...state,
posts: action.posts
}
}
if(action.type === GET_POST){
return {
...state,
post: action.post
}
}
return state
}
export const specialityReducer = (state = {}, action) => {
if(action.type === GET_ALL_SPECIALITIES){
return {
...state,
specialities: action.specialities
}
}
if(action.type === GET_SPECIALITY)
return {
...state,
speciality: action.speciality
}
return state
}
export const courseReducer = (state = {}, action) => {
if (action.type === GET_ALL_COURSES){
return {
...state,
courses: action.courses
}
}
if (action.type === GET_COURSE){
return {
...state,
course: action.course
}
}
return state
}
export const teacherReducer = (state = {}, action) => {
if(action.type === GET_ALL_TEACHERS){
return {
...state,
teachers: action.teachers
}
}
return state
}
export const lessonReducer = (state = {}, action) => {
if (action.type === GET_LESSON){
return {
...state,
lesson: action.lesson
}
}
return state
}
store.js
import { createStore, combineReducers, applyMiddleware } from 'redux'
import { composeWithDevtools } from 'redux-devtools-extension'
import thunk from 'redux-thunk'
import { postReducer,
specialityReducer,
courseReducer,
teacherReducer,
lessonReducer
} from './reducers'
export default createStore(combineReducers({postReducer, specialityReducer, courseReducer, teacherReducer, lessonReducer}),composeWithDevtools(applyMiddleware(thunk)))
答案 0 :(得分:0)
尝试将对象传递给CombineReducers,并在所有reducer之前给出名称。 CombineReducers({reducerName:reducerFunction});