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:
and now its time to see the output in Virtual Device, please see below:
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đź’»
Top comments (0)
Some comments have been hidden by the post's author - find out more