Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3ae2a40

Browse files
redux-persist added
1 parent 391b7b6 commit 3ae2a40

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

‎src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import "./App.css";
33
import CardList from "./Containers/cardContainer";
44
import Form from "./Containers/formContainer";
55

6+
7+
68
// Redux Persist takes your Redux state object and saves it to persisted storage.
79
// Then on app launch it retrieves this persisted state and saves it back to redux.
810

‎src/index.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,26 @@ import { persistStore, persistReducer } from 'redux-persist';
1010
import storage from 'redux-persist/lib/storage';
1111
import rootReducer from './rootReducer'
1212
import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2';
13+
import { PersistGate } from 'redux-persist/lib/integration/react';
14+
import * as t from './Constants';
1315

14-
// BLOG
16+
const persistConfig = {
17+
key: 'root',
18+
storage: storage,
19+
stateReconciler: autoMergeLevel2,
20+
blacklist: [],
21+
whitelist: [t.CARD_LIST_REDUCER]
22+
};
1523

16-
const store = createStore(
17-
rootReducer
18-
);
24+
const persistreducer = persistReducer(persistConfig,rootReducer);
25+
conststore=createStore(persistreducer);
26+
constpersistor=persistStore(store);
1927

2028
ReactDOM.render((
2129
<Provider store={store}>
30+
<PersistGate persistor={persistor}>
2231
<App />
32+
</PersistGate>
2333
</Provider>
2434
), document.getElementById('root'));
2535

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /