Redux-persist,具有白名单,黑名单的嵌套持久者

时间:2019-12-13 08:49:26

标签: redux redux-persist

https://github.com/rt2zz/redux-persist包含以下示例

我认为,如果您将auth列入黑名单,则整个reducer都将被列入黑名单。
为什么在somethingTemporary内再次将auth列入黑名单?

import { combineReducers } from 'redux'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import { authReducer, otherReducer } from './reducers'

const rootPersistConfig = {
  key: 'root',
  storage: storage,
  blacklist: ['auth']
}

const authPersistConfig = {
  key: 'auth',
  storage: storage,
  blacklist: ['somethingTemporary']
}

const rootReducer = combineReducers({
  auth: persistReducer(authPersistConfig, authReducer),
  other: otherReducer,
})

export default persistReducer(rootPersistConfig, rootReducer)

如果要将嵌套键foo.bar列入白名单,白名单又如何呢?您应该在顶层将foo列入白名单,在bar级别将foo列入白名单吗? / p>

0 个答案:

没有答案