persist state over reload
Summary: The selected device, app and plugin are not persisted over a reload using `redux-persist`. Reviewed By: jknoxville Differential Revision: D8836481 fbshipit-source-id: 3ace1a950a200255d5daf77791d706ede0ff2138
This commit is contained in:
committed by
Pascal Hartig
parent
1f977f4844
commit
37425e7ae8
23
src/init.js
23
src/init.js
@@ -14,15 +14,36 @@ import Logger from './fb-stubs/Logger.js';
|
||||
import App from './App.js';
|
||||
import BugReporter from './fb-stubs/BugReporter.js';
|
||||
import {createStore} from 'redux';
|
||||
import {persistStore, persistReducer} from 'redux-persist';
|
||||
import createFilter from 'redux-persist-transform-filter';
|
||||
import storage from 'redux-persist/lib/storage/index.js';
|
||||
import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2';
|
||||
import reducers from './reducers/index.js';
|
||||
import dispatcher from './dispatcher/index.js';
|
||||
import {setupMenuBar} from './MenuBar.js';
|
||||
const path = require('path');
|
||||
|
||||
const store = createStore(
|
||||
const reducer: typeof reducers = persistReducer(
|
||||
{
|
||||
key: 'root',
|
||||
stateReconciler: autoMergeLevel2,
|
||||
transforms: [
|
||||
createFilter('connections', [
|
||||
'userPreferredDevice',
|
||||
'userPreferredPlugin',
|
||||
'userPreferredApp',
|
||||
]),
|
||||
],
|
||||
storage,
|
||||
},
|
||||
reducers,
|
||||
);
|
||||
|
||||
const store = createStore(
|
||||
reducer,
|
||||
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
|
||||
);
|
||||
persistStore(store);
|
||||
|
||||
const logger = new Logger();
|
||||
const bugReporter = new BugReporter(logger);
|
||||
|
||||
Reference in New Issue
Block a user