简体   繁体   English

无法处理错误:redux-promise-middleware中的“中间件不是函数”?

[英]Unable to handle error: `middleware is not a function' in redux-promise-middleware?

I am trying to use redux-promise-middleware in my app, but when I am trying to run my app error comes with an error message: 'middleware is not a function or middleware is null'. 我正在尝试在我的应用程序中使用redux-promise-middleware,但是当我尝试运行我的应用程序时,错误出现了一条错误消息:“中间件不是函数或中间件为空”。

I tried to use middleware without a function as suggested in redux async docs, but still error is coming. 我试图使用Redux异步文档中建议的不带功能的中间件,但仍然会出现错误。

configureStore.js configureStore.js


import { createStore, applyMiddleware } from 'redux'
import app from './reducers/index';
import PromiseMiddleware from 'redux-promise-middleware';

const configureStore = () => {
    let middleware = applyMiddleware(PromiseMiddleware());
    let store = createStore(app, middleware);
    return store
};

export default configureStore;

index.js index.js


import React from 'react'
import { AppRegistry } from 'react-native';
import App from './App';
import { Provider } from 'react-redux'
import configureStore from './configureStore'

const store = configureStore();

const ReduxMiddleware = () => {
    <Provider store={store}>
        <App />
    </Provider>
}

AppRegistry.registerComponent('ReduxMiddleware', () => ReduxMiddleware);

Please anybody, suggest to me that why I am facing this error. 请任何人向我建议为什么我要面对这个错误。 I am new to redux. 我是Redux的新手。

import promiseMiddleware from 'redux-promise-middleware';

composeStoreWithMiddleware = applyMiddleware(
   promiseMiddleware,
)(createStore);

And not : PromiseMiddleware() 不是:PromiseMiddleware()

(not uppercase and w/o () ) (不是大写,没有())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我将使用什么来启动异步Redux以下Thunk或Saga或Observable或Redux Promise Middleware? - What would I use for start async Redux out of following Thunk or Saga or Observable or Redux Promise Middleware? redux 中是否需要中间件和增强器? - Are middleware and enhancers necessary in redux necessary? React Native / Redux-中间件中的存储为空 - React Native / Redux - store is empty in middleware 如何实现 redux 中间件来刷新 JWT 令牌? - how to implement redux middleware to refresh JWT tokens? 使用 Redux 工具包从商店中删除中间件 - Remove middleware from store with Redux Toolkit 无法使用 zustand 持久化中间件 - Unable to use zustand persist middleware React Native 和 Redux - 错误:操作必须是普通对象。 使用自定义中间件进行异步操作 - React Native & Redux - Error: Actions must be plain objects. Use custom middleware for async actions 在Redact中使用React Native中的NetInfo中间件 - Using NetInfo middleware in React Native with Redux React Native 中的 Redux-axios 中间件无法正常工作 - Redux-axios middleware in React Native is not working React/Redux... 错误:操作必须是普通对象。 使用自定义中间件进行异步操作 - React/Redux… Error: Actions must be plain objects. Use custom middleware for async actions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM