Ayoub Bani
Ayoub Bani

Reputation: 319

How to store only a part of the redux state using redux-persist

How can I store only a part of the redux-state using redux-persist. For example I have the following state

const initialState = {
data: [],
fetched: false,
loadingUser: false
}

How can I store only the data without saving fetched and loadingUser boolean with redux-persist

Upvotes: 0

Views: 1203

Answers (1)

dwjohnston
dwjohnston

Reputation: 11771

You can use the 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
};

Upvotes: 5

Related Questions