Storage adapter to use electron-store with redux-persist
npm i -S electron-store redux-persist-electron-storage
yarn add electron-store redux-persist-electron-storage
To use redux-persist-electron-storage, configure redux-persist according to its documentation.
Modify the classic redux-persist configuration as follows:
redux-persist/lib/storage
anymore, as we use an alternative storage.redux-persist-electron-storage
:import createElectronStorage from "redux-persist-electron-storage";
persistReducer
in order to use the storage dedicated to Electron:const persistConfig = {
key: 'root',
storage: createElectronStorage()
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
You can either pass an instance of electron-store
or pass options like below:
const electronStore = new ElectronStore()
createElectronStorage({
electronStore
})
createElectronStorage({
electronStoreOpts: {
encryptionKey: 'MY_ENCRYPTION_KEY'
}
})
Hint: The passed instance is preferred over passed options