Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 861
wd3 Avatar asked Sep 07 '25 03:09

wd3


1 Answers

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 ;)

like image 88
wd3 Avatar answered Sep 09 '25 19:09

wd3