DEV Community

Cover image for react-redux error store does not have a valid reducer (solution)
Osman Forhad
Osman Forhad

Posted on • Edited on

1

react-redux error store does not have a valid reducer (solution)

Alt Text

so now we have an issue which is: Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.
tody we will see how to solve this silly mistake
.
I have seen this error just now because I made a mistake in which is I take my reducer file is empty that's why I got this error. to solve this error I write the following code in my reducer.js file please see the reducer.js file code below:

const initialState = {
houses: []
}
//export default reducer
export default function(state = initialState, action){
return state;
}

after that, I imported and calling this reducer.js file in my store.js file
please see the store.js file code in below:

import { createStore, applyMiddleware, combineReducers } from 'redux';
import thunk from 'redux-thunk';
import { composeWithDevTools } from 'redux-devtools-extension';

//import the developer created component
import houseReducer from './reducers/houseReducer';

//combining reducer
const rootReducer = combineReducers({
house: houseReducer //calling the reducer file
});

//create middleware
const middleware = composeWithDevTools(applyMiddleware(thunk));

//creating store
export default createStore(rootReducer, middleware);

after all that I restart again my server using the expo start command
it's working nicely there is no error in my terminal
see below:
Alt Text
and now its time to see the output in Virtual Device, please see below:

Alt Text

also, this type of error can be if we mistake the file spelling or we forgot to import the reducer file into the store file or if made mistake in including the file path.

that's it
.
Happy Coding.
osman forhad
Mobile & Web Application Developer💻

Sentry mobile image

Mobile Vitals: A first step to Faster Apps

Slow startup times, UI hangs, and frozen frames frustrate users—but they’re also fixable. Mobile Vitals help you measure and understand these performance issues so you can optimize your app’s speed and responsiveness. Learn how to use them to reduce friction and improve user experience.

Read the guide →

Top comments (0)

Some comments have been hidden by the post's author - find out more

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay