Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom redux persist version for redux-offline
//@flow
import { createStore, applyMiddleware } from 'redux';
import storage from 'redux-persist/lib/storage'
import { composeWithDevTools } from 'redux-devtools-extension';
import { persistStore, persistReducer } from 'redux-persist';
import thunk from 'redux-thunk';
import reducer from 'reducers';
import { createOffline } from '@redux-offline/redux-offline';
import offlineConfig from '@redux-offline/redux-offline/lib/defaults/index';
const persistConfig = {
key: 'root',
storage
};
const {
middleware: offlineMiddleware,
enhanceReducer: offlineEnhanceReducer,
enhanceStore: offlineEnhanceStore
} = createOffline({
...offlineConfig,
persist: false
});
const persistedReducer = persistReducer(
persistConfig,
offlineEnhanceReducer(reducer)
);
export default function configureStore() {
const store = createStore(
persistedReducer,
composeWithDevTools(
offlineEnhanceStore,
applyMiddleware(thunk, offlineMiddleware)
)
);
const persistor = persistStore(store);
return { persistor, store };
}
@vallimaiel

This comment has been minimized.

Copy link

@vallimaiel vallimaiel commented Feb 28, 2019

i too came up with the same issue but even if i remove redux persist ,the crash appears to continue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment