Redux createStore 错误:预期reducer 是一个函数 [英] Redux createStore error: Expected the reducer to be a function
本文介绍了Redux createStore 错误:预期reducer 是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 createStore
上遇到错误,我不明白为什么.
I'm getting an error on createStore
and I'm not understanding why.
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
import thunk from "redux-thunk"
import promise from "redux-promise-middleware"
import * as reducers from './reducers';
const middleware = applyMiddleware(promise(), thunk);
export default createStore(reducers, middleware);
以上是我的代码,我在行中收到错误
Above is my code and I get the error in the line
const middleware = applyMiddleware(promise(), thunk);
错误是期望Reducer是一个函数.我正在使用 React Native 0.37 和最新版本的 redux、redux-thunk 和 redux-promise-middleware.reducers 是 combineReducers 的结果.
The error is Expected the Reducer to be a function. I'm using React Native 0.37 and the latest version of redux, redux-thunk and redux-promise-middleware. The reducers is the result of combineReducers.
提前致谢.
推荐答案
import * as reducers from './reducers';
reducers
不可能是一个函数.您将获得一个对象,每个导出都作为一个属性.你可能想要:
There's no way that reducers
is a function. You're going to get an object with each export as a property. You probably want:
import reducers from './reducers';
这篇关于Redux createStore 错误:预期reducer 是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文