当前位置: 首页 > 知识库问答 >
问题:

存储错误使用React.js-TypeError:对象(...)是不是一个函数反应

昌和悦
2023-03-14

我想做我的水疗店。我制作了我需要的每件东西的还原器,但是当我呈现页面时,我收到了这条消息

TypeError:对象(…)不是功能模块/src/redux/store。jsc:/Users/Mycomputer/Desktop/Projects/React/2020\u 03\u 29\u workshop/src/redux/store。js:13

13 |导出默认createStore(rootReducer、composeWithDevtools(applyMiddleware(thunk)))

减速器。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
}

百货商店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)))

共有1个答案

欧盛
2023-03-14

尝试将对象传递给组合减速器,并在所有减速器之前给出名称。组合减速机({reducerName:reducerFunction});

 类似资料:
  • 问题内容: 我正在尝试在React中创建一个项目,并且正在使用Firebase。在我的react-redux- firebase项目中,有一行代码出错,但我无法解决。如何解决此“ TypeError:Object(…)不是函数” 我已经搜索了此问题,但无法解决该问题。 我正在关注一个React版本为16.4.1的教程。我不确定这是否是问题 index.js文件 如果我注释掉reatReduxFir

  • 问题内容: 自从我对JavaScript和React感到陌生以来,我确实在找出正确的语法方面遇到了问题。 这是我的问题: 应该调用该函数,但不会。我收到此错误,无法找出原因。回调可以正常工作。 当我尝试这种语法时,在编译时会立即出现错误。那是因为电子书吗? 问题答案: 当您使用ES6类而不是React.createClass时,它不会自动绑定 this 。 之所以: React.createCla

  • 问题内容: 我在尝试简化导入时遇到webpack TypeError。以下代码可以正常工作。在这里,我导入了一个从调用的React高阶组件(HOC)。 core / components / form / index.js (对进行命名输出) login-form.jsx (导入和使用) 但是,我想将导入简化为just 。所以,我再出口的和进口它。请参见下面的代码: core / index.js

  • 问题内容: 我正在尝试从Wikipedia主页提取所有链接,但是此代码显示TypeError:“ WebElement”对象不是可迭代的错误。 问题答案: 问题是您正在使用哪个仅返回一个WebElement(不可迭代),即返回一个WebElement列表。 解决方案:替换为 参考:Selenium-Python文档

  • 在我的redux js应用程序(google appengine后端)中,当打开包含根组件的页面时,我会收到以下警告和错误消息。 警告:失败的proType:无效的prop类型的提供给,预期的。检查的渲染方法。bundle.js:6169 警告:propType失败:提供给的类型的无效,应为。检查的渲染方法。捆js:6169 警告:失败的上下文类型:类型的无效子上下文提供给,预期的。检查的渲染方法

  • 我有这个功能: 不知什么原因,我得到以下错误: 我看了这篇文章:https://stackoverflow.com/questions/44176021/nodejs-res-send-is-not-a-function 它看起来像另一只虫子。 我怎样才能修好它?