Stanly Medjo
Stanly Medjo

Reputation: 95

Redux-persist how to persist some state

Everyone i have been using redux-persist for a while now and is really a great tool, but the problem is that it just persist all my states (reducers), i will like to know is there is a way to choose which states are to be persist. Thanks

Upvotes: 0

Views: 796

Answers (1)

karl
karl

Reputation: 1936

In your redux-persist config you can add a whitelist or blacklist depending on your need. These take an array of the states you would like to include (whitelist) or ignore (blacklist).

For example:

const persistConfig = {
  key: 'root',
  blacklist: ['state-not-to-be-persisted']
}

Official documentation

Upvotes: 4

Related Questions