Open mjftw opened 4 years ago
I'm sure I've followed the documentation exactly, but my state is still not persisting.
I'm assuming this isn't a bug, but if not I have no idea what I'm doing wrong.
Can anyone see what's going on here?
rootReducer.js
import {combineReducers} from 'redux'; import {workspacesReducer} from './workspaces/reducers'; import {reposReducer} from './repos/reducers'; import {refreshReducer} from './refresh/reducers'; import {apisReducer} from './apis/reducers'; import {pullRequestsReducer} from './pullRequests/reducers'; export default combineReducers({ workspaces: workspacesReducer, repos: reposReducer, refresh: refreshReducer, apis: apisReducer, pullRequests: pullRequestsReducer });
store.js
import {createStore, applyMiddleware} from 'redux'; import thunk from 'redux-thunk'; import {composeWithDevTools} from 'redux-devtools-extension'; import {persistStore, persistReducer} from 'redux-persist'; import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2'; import storage from 'redux-persist/lib/storage'; import rootReducer from './rootReducer'; const persistConfig = { key: 'root', storage: storage, stateReconciler: autoMergeLevel2, blacklist: [ 'apis' ] }; const persistedReducer = persistReducer(persistConfig, rootReducer); export const store = createStore( persistedReducer, undefined, // Get initial state from subdirectory reducers composeWithDevTools( applyMiddleware(thunk) ) ); export const persistor = persistStore(store);
App.js
import React, {Component} from 'react'; import {Provider} from 'react-redux'; import {Grommet} from 'grommet'; import {PersistGate} from 'redux-persist/integration/react'; import {store, persistor} from './redux/store'; import BitbucketKeyManager from './containers/BitbucketKeyManager'; import RefreshManager from './containers/RefreshManager'; import MainWindow from './presenters/MainWindow'; const theme = { global: { font: { family: 'Roboto', size: '14px', height: '20px', }, colors: { background: 'light-1', focus: 'neutral-3' } }, }; class App extends Component { render() { return ( <Provider store={store}> <PersistGate loading={null} persistor={persistor}> <Grommet theme={theme}> <BitbucketKeyManager /> <RefreshManager /> <MainWindow /> </Grommet> </PersistGate> </Provider> ); } } export default App;
I think this is not a bug you are missing whitelist from your persistConfig
check this basic config https://github.com/rt2zz/redux-persist#blacklist--whitelist
I'm sure I've followed the documentation exactly, but my state is still not persisting.
I'm assuming this isn't a bug, but if not I have no idea what I'm doing wrong.
Can anyone see what's going on here?
rootReducer.js
store.js
App.js