Search code examples
reactjsreact-reduxredux-persist

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


Solution

  • 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