Skip to content

Instantly share code, notes, and snippets.

@jonra1993
Created March 15, 2021 01:28
Show Gist options
  • Save jonra1993/71642a22a8657bb2ae5f607c160d9f2e to your computer and use it in GitHub Desktop.
Save jonra1993/71642a22a8657bb2ae5f607c160d9f2e to your computer and use it in GitHub Desktop.
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