Redux商店没有有效的reducer,带有combineReducers和有效的reducer

时间:2017-06-07 20:44:09

标签: javascript reactjs redux

import { createStore, combineReducers } from 'redux'
const reducer = (state = {}, action) => state
const rootReducer = combineReducers(reducer)
let store = createStore(rootReducer)
export default store

创建商店时会触发警告:

Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.

当我尝试使用任何商店方法时,会再次出现此警告。

1 个答案:

答案 0 :(得分:5)

错误很简单 - 您没有将对象传递给combineReducers:

const rootReducer = combineReducers({ reducer })

这将解决问题。