Search code examples
reactjsreduxreact-reduxreducedeprecated

Uncaught Error: "reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers


recently i had this error in my browser's console: Uncaught Error: "reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers

so i was trying to solve it for few hours but nothing helped ...

from the very beginning when i created this script i copied some parts of it from the other my script that i created half a year ago or so... then i found some functions deprecated and tried to upgrade them...

my old redux-store.js script was like this:

...
let reducers = combineReducers({

     auth: auth_reducer,
     admin: admin_reducer,
     index: index_reducer
})


const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
    reducers, 
    composeEnhancers(
        applyMiddleware(thunkMiddleware)
    )
);
...

but then i changed (upgraded) it and error from title appeared... error


Solution

  • nothing helped untill i changed argument name in function configureStore() from reducers to just reducer

    like this:

    ...
    let reducers = combineReducers({
         book: booking_reducer,
         admin: admin_reducer,
    })
    
    const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
    const store = configureStore(
            {reducer:reducers},
            composeEnhancers(
                applyMiddleware(thunkMiddleware)
            )
        );
    ...
    

    I hope this post will help someone to save hours of debugging ;)