Redux thunk in react native

风格不统一 提交于 2019-12-24 11:31:00

问题


I'm getting and error on createStor that 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);

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.

Thanks in advance.


回答1:


import * as reducers from './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';


来源:https://stackoverflow.com/questions/40617901/redux-thunk-in-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!