反应redux商店不是一个功能

时间:2016-01-28 11:27:03

标签: reactjs redux

const rootReducer = combineReducers({
  router: routerStateReducer,
  todos,
})

const createStoreWithMiddleware = compose(
  applyMiddleware(thunk),
  reduxReactRouter({ routes, createHistory })
  )(createStore)(reducer);


export default function configureStore(initialState) {
  const store = createStoreWithMiddleware(rootReducer, initialState)

它给了我createStoreWithMiddleware不是一个功能..为什么会这样?

1 个答案:

答案 0 :(得分:1)

您正在执行compose的结果(返回一个函数)。因此,不是将createStoreWithMiddleware设置为返回的函数,而是将其设置为带有变量reducer的执行结果。

由于您上面定义了reducer,因此不确定此上下文中的变量rootReducer是什么。你的代码可能应该是:

const createStoreWithMiddleware = compose(
  applyMiddleware(thunk),
  reduxReactRouter({ routes, createHistory })
)(createStore)

这样做会将createStoreWithMiddleware定义为扩展的createStore函数,然后可以接收您的rootReducerinitialState