Skip to content

Instantly share code, notes, and snippets.

@jarvisluong
Created September 22, 2018 18:50
  • Star 12 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jarvisluong/f14872b9c7ed00bc2afc89c4622e3b55 to your computer and use it in GitHub Desktop.
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
Copy link

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