2017-07-24 91 views
0

无法发现任何缺陷在我的代码我自己,我的反应终极版applyMiddleware不是一个函数

Uncaught TypeError: (0 , _reactRedux.applyMiddleware) is not a function

import { applyMiddleware, createStore } from 'react-redux' 
import { promiseMiddleware } from './middleware' 

const defaultState = { 
    appName: 'conduit', 
} 

const reducer = (state = defaultState, action) => { 
    switch(action.type) { 
     case 'HOME_PAGE_LOADED': 
      return { ...state, articles: action.payload.articles } 
    } 
    return state 
} 

const middleware = applyMiddleware(promiseMiddleware) 

const store = createStore(reducer, middleware) 

export default store 

任何线索有什么错错误?

+1

不要在那[来自终极版,还没有反应过来,终极版?(http://redux.js.org/docs/api/applyMiddleware.html) – corvid

+0

是什么promiseMiddleware样子? –

回答

0

你有你的进口混合起来。 createStoreapplyMiddleware是Redux软件包的一部分,而不是React-Redux。您需要:

import {createStore, applyMiddleware} from "redux"; 
-1

你需要调用中间件的承诺像promiseMiddleware文本在此之后

const middleware = applyMiddleware(promiseMiddleware()) 

i.e-使用功能支架。

查看文档这里 -
enter image description here

+0

试图使用你的代码,同样的错误 –

+0

你有没有安装promiseMiddleware的npm? – Arshmeet

+0

我在我的一个项目中使用了这个中间件。我通过npm安装它,它工作正常。如果你想我可以分享代码 – Arshmeet

相关问题