In my react-native app, I am using redux-persist to display data present in the store if the user is offline. But after adding redux-persist I am getting error state.merge is not a function
. I think it's an error of Immutability. please help me to solve this problem.
rootChangeReducer.js
import * as types from '../actions/login/ActionTypes';
import Immutable from 'seamless-immutable';
const initialState = Immutable({
root: undefined, // 'login' / 'after-login' / 'register'
});
//root reducer
export function root(state = initialState, action = {}) {
switch (action.type) {
case types.ROOT_CHANGED:
return state.merge({
root: action.root
});
default:
return state;
}
}
and configureStore.js
import { createStore, combineReducers, compose, applyMiddleware } from "redux";
import thunk from "redux-thunk";
import { persistStore, persistCombineReducers } from 'redux-persist';
import storage from 'redux-persist/es/storage';
import masjids from "./reducers/productReducer";
import { root } from "./reducers/rootReducer";
const config = {
key: 'root',
storage,
}
const reducers = {
root,
masjids
}
const reducer = persistCombineReducers(config, reducers)
let composeEnhancers = compose;
if (__DEV__) {
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
}
const configureStore = () => {
return createStore(reducer, composeEnhancers(applyMiddleware(thunk)));
};
export default configureStore;
Thanks in advance.