小编Ice*_*der的帖子

尽管为createStore()提供了initialState,为什么我在初始化期间得到"Reducer [...]未定义"?

我在redux createStore方法中设置了InitialState,并将InitialState作为第二个参数

我在浏览器中出错:

<code>Uncaught Error: Reducer "postsBySubreddit" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined.</code>
Run Code Online (Sandbox Code Playgroud)

代码在这里:

import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk'
import createLogger from 'redux-logger'
import rootReducer from '../reducers/reducers'
import Immutable from 'immutable'
const loggerMiddleware = createLogger()
//const initialState=0
function configureStore() {
    return createStore(
    rootReducer,
     {postsBySubreddit:{},selectedSubreddit:'reactjs'},
     applyMiddleware(
     thunkMiddleware,
    loggerMiddleware
  )
 )
}
  export default configureStore …
Run Code Online (Sandbox Code Playgroud)

javascript redux react-redux

57
推荐指数
7
解决办法
3万
查看次数

标签 统计

javascript ×1

react-redux ×1

redux ×1