Redux persist with version information.
yarn add https://github.com/devx-agency/redux-persist-check-version-transform
const persistWhitelist = ['userData', 'product']
const reduxStore = {
userData: {
redux: require('../Redux/UserDataRedux'),
blacklist: ['username'],
encrypt: true,
version: 1
},
product: {
redux: require('../Redux/ProductRedux'),
whitelist: ['productName'],
version: 1
}
}
const pass = 'pass'
const persistConfig = { // 'redux-persist' config
key: 'devx',
storage: localForage,
transforms: [immutableTransform(), persistCheckVersionTransform(reduxStore, persistWhitelist, pass)],
whitelist: persistWhitelist
}
Variable | Type | Description |
---|---|---|
persistWhitelist | Array | which redux will be stored |
reduxStore | {[key: string]: Options} | configuration of persist tranform |
pass | string | password for encrypted data |
Variable | Type | Description |
---|---|---|
redux | imported redux | |
blacklist | Array | variables will not be persisted |
whitelist | Array | only this variables will be persisted |
encrypt | boolean | default false if data should be persisted |
version | number | data version |
When version is incresed, old data will be deleted.
import { stateReconcilerImmutable } from 'persist-check-version-transform'