Hi there,
After migration and making the changes in my code I receive this error:
Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.
Here's my store code:
import { createStore , applyMiddleware , compose} from 'redux';
import thunk from 'redux-thunk';
import reducers from './../reducers';
import {persistStore, persistCombineReducers} from "redux-persist";
import storage from 'redux-persist/lib/storage';
const middleware = [ thunk ];
const config = {
key: 'primary',
storage,
}
let reducer = persistCombineReducers(config, reducers);
const store = createStore(
reducer,
undefined,
compose(
applyMiddleware(...middleware)
)
);
persistStore(
store,
config,
null,
() => {store.getState()}
)
export default store;
and here's my reducer:
import { combineReducers } from 'redux';
import user from './userReducer';
const rehydrated = (state = false , action) => {
switch (action.type) {
case "persist/REHYDRATE" :
return true;
break;
default:
return state;
}
}
export default combineReducers({
rehydrated,
user
});
Any idea?
I found the issue. the reason was I used combined reducers twice. Once in reducers and once in persistCombineReducers in store.
so need to change this in reucers:
export default combineReducers({
rehydrated,
user
});
to
export default {
rehydrated,
user
};
Most helpful comment
I found the issue. the reason was I used combined reducers twice. Once in reducers and once in persistCombineReducers in store.
so need to change this in reucers:
to