From 7a1078f53d65697e4c5d8791e65ba5e468c56013 Mon Sep 17 00:00:00 2001 From: marcinbodnardesktop Date: Wed, 12 May 2021 21:54:28 +0200 Subject: [PATCH] redux-persist configuration (#1666) --- src/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index e54f62847f..39af8dc88f 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,11 @@ import ReactDOM from 'react-dom' import { initSentry } from './utils/sentry' import { createStore } from 'redux' + +import { persistStore, persistReducer } from 'redux-persist' +import storage from 'redux-persist/lib/storage' +import { PersistGate } from 'redux-persist/integration/react' + import { Provider } from 'react-redux' import { LocalizeProvider } from 'react-localize-redux'; import { createBrowserHistory } from 'history' @@ -17,9 +22,17 @@ import Routing from './components/Routing' initSentry(); +const persistConfig = { + key: 'root', + storage, +} + const history = createBrowserHistory() -export const store = createStore(createRootReducer(history), createMiddleware(history)) +const persistedReducer = persistReducer(persistConfig, createRootReducer(history)) + +export const store = createStore(persistedReducer, createMiddleware(history)) +let persistor = persistStore(store) ReactDOM.render(