如何使用 redux-persist 只存储部分 redux 状态
How to store only a part of the redux state using redux-persist
如何使用 redux-persist 仅存储部分 redux-state。例如我有以下状态
const initialState = {
data: [],
fetched: false,
loadingUser: false
}
如何只存储数据而不用 redux-persist 保存 fetched 和 loadingUser 布尔值
您可以使用 whitelist and blacklist functionality, as outlined in the documentation.
//in your redux store config
const persistConfig = {
key: 'root',
storage: storage,
whitelist: ['data'] // only data will be persisted
};
如何使用 redux-persist 仅存储部分 redux-state。例如我有以下状态
const initialState = {
data: [],
fetched: false,
loadingUser: false
}
如何只存储数据而不用 redux-persist 保存 fetched 和 loadingUser 布尔值
您可以使用 whitelist and blacklist functionality, as outlined in the documentation.
//in your redux store config
const persistConfig = {
key: 'root',
storage: storage,
whitelist: ['data'] // only data will be persisted
};