|
@@ -1,12 +1,30 @@
|
1
|
|
-import reducer from "../reducer/index"
|
2
|
1
|
import { createStore, compose, applyMiddleware } from 'redux';
|
3
|
2
|
import thunk from 'redux-thunk';
|
|
3
|
+import { persistStore, persistReducer } from 'redux-persist'
|
|
4
|
+import storage from 'redux-persist/lib/storage'
|
|
5
|
+import reducer from "../reducer/index"
|
4
|
6
|
|
5
|
7
|
const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
6
|
8
|
|
|
9
|
+const persistConfig = {
|
|
10
|
+ key: 'root',
|
|
11
|
+ storage,
|
|
12
|
+}
|
|
13
|
+
|
|
14
|
+const persistedReducer = persistReducer(persistConfig, reducer)
|
|
15
|
+
|
|
16
|
+// const store = createStore(
|
|
17
|
+// reducer,
|
|
18
|
+// composeEnhancer(applyMiddleware(thunk))
|
|
19
|
+// );
|
|
20
|
+
|
|
21
|
+// export default store;
|
|
22
|
+
|
7
|
23
|
const store = createStore(
|
8
|
|
- reducer,
|
9
|
|
- composeEnhancer(applyMiddleware(thunk)),
|
10
|
|
-);
|
|
24
|
+ persistedReducer,
|
|
25
|
+ composeEnhancer(applyMiddleware(thunk))
|
|
26
|
+ );
|
|
27
|
+
|
|
28
|
+const persistor = persistStore(store);
|
11
|
29
|
|
12
|
|
-export default store;
|
|
30
|
+export { store, persistor };
|