Created
March 15, 2021 01:28
-
-
Save jonra1993/71642a22a8657bb2ae5f607c160d9f2e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { configureStore } from '@reduxjs/toolkit'; | |
import storage from 'redux-persist/lib/storage' | |
import { persistStore, persistReducer } from 'redux-persist'; | |
import { encryptTransform } from 'redux-persist-transform-encrypt'; | |
import thunk from 'redux-thunk' | |
import rootReducer from './rootReducer'; | |
const ENABLE_REDUX_DEV_TOOLS = true; | |
const encryptor = encryptTransform({ | |
secretKey: 'Super-Secret-key-jrtec', | |
onError: function (error) { | |
// Handle the error. | |
}, | |
}) | |
const persistConfig = { | |
key: 'root', | |
storage: storage, | |
timeout: null, | |
transforms: [encryptor] | |
}; | |
const persistedReducer = persistReducer(persistConfig, rootReducer); | |
export const store = configureStore({ | |
reducer: persistedReducer, | |
devTools: ENABLE_REDUX_DEV_TOOLS, | |
middleware: [thunk] | |
}); | |
export const persistor = persistStore(store); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment