Skip to content Skip to sidebar Skip to footer

Reducers Get Function Not Object In Redux, What's Wrong With It?

I got a error at my react and redux project. and I not found how to resolve it. this is error message: The previous state received by the reducer has unexpected type of 'Function'

Solution 1:

This is the old that used to work:

const store = createStore(reducers, applyMiddleware(...middleware),  window.devToolsExtension ? window.devToolsExtension() : f => f)

Now you have to convert it to:

const store = redux.createStore(
    rootReducer,
    initialState,
    redux.compose(
        redux.applyMiddleware(...middleware),
        window.devToolsExtension ? window.devToolsExtension() : f => f
    )
);

Solution 2:

I know that...

the params that second at createStore is initialState, not middleware..

Solution 3:

The error occurs because the keys of your state object must match that of the object you passed to combineReducers. Check this doc for more details combineReducers

Post a Comment for "Reducers Get Function Not Object In Redux, What's Wrong With It?"