Created
September 22, 2018 18:50
-
-
Save jarvisluong/f14872b9c7ed00bc2afc89c4622e3b55 to your computer and use it in GitHub Desktop.
Custom redux persist version for redux-offline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@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 }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i too came up with the same issue but even if i remove redux persist ,the crash appears to continue