33 lines
855 B
JavaScript
33 lines
855 B
JavaScript
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
import {persistReducer, persistStore} from 'redux-persist';
|
|
import {createStore, compose, applyMiddleware} from 'redux';
|
|
import {name as appName} from '../../app.json';
|
|
import rootReducer from '../reducers';
|
|
import thunk from 'redux-thunk';
|
|
|
|
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
|
|
|
const persistConfig = {
|
|
key: 'root',
|
|
blacklist: [],
|
|
whitelist: ['contacts'],
|
|
keyPrefix: appName,
|
|
storage: AsyncStorage,
|
|
};
|
|
|
|
const persistedReducer = persistReducer(persistConfig, rootReducer);
|
|
|
|
const configureStore = () => {
|
|
return createStore(
|
|
persistedReducer,
|
|
composeEnhancers(applyMiddleware(thunk)),
|
|
);
|
|
};
|
|
|
|
export default () => {
|
|
let store = configureStore();
|
|
let persistor = persistStore(store);
|
|
|
|
return {store, persistor};
|
|
};
|