-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore.js
More file actions
37 lines (36 loc) · 1021 Bytes
/
store.js
File metadata and controls
37 lines (36 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Imports: Dependencies
import AsyncStorage from '@react-native-community/async-storage';
import { createStore, applyMiddleware } from 'redux';
import { createLogger } from 'redux-logger';
import { persistStore, persistReducer } from 'redux-persist';
import hardSet from 'redux-persist/lib/stateReconciler/hardSet'
// Imports: Redux
import { rootReducer, initialState } from './reducers';
// Middleware: Redux Persist Config
const persistConfig = {
// Root
key: 'root',
// Storage Method (React Native)
storage: AsyncStorage,
// State reconciler
stateReconciler: hardSet,
// Whitelist
whitelist: ['references', 'history', 'citations']
};
// Middleware: Redux Persist Persisted Reducer
const persistedReducer = persistReducer(persistConfig, rootReducer);
// Redux: Store
const store = createStore(
persistedReducer,
initialState,
applyMiddleware(
createLogger(),
),
);
// Middleware: Redux Persist Persister
const persistor = persistStore(store);
// Exports
export {
store,
persistor,
};