TransWikia.com

redux-persist - how do you blacklist/whitelist nested state

Stack Overflow Asked by David Browning on December 23, 2020

So I have a credentials object which contains a password and a username

payload: Object
  credentials: Object
    password: ""
    username: ""

and I want to blacklist password in the reducer configuration, something like

const authPersistConfig = {
    key: 'AuthReducer',
    storage: storage,
    blacklist: ['credentials.password']
};

If I use this code, both the credential states end up being blacklisted. I want to persist the username but not the password.

It might be that redux-persist only persists top-level state or it might be a syntax error, or something else entirely – any ideas?

Many thanks

2 Answers

Or if you want not completely remove the keys but just clear any of data in any nested state objects, here is example using createTransform from 'redux-persist'

How to make redux-persist blacklist for nested state?

Answered by Stich on December 23, 2020

You can use the NPM package called redux-persist-transform-filter as described in redux-persist issue #277 - Whitelist reducer subproperty only?

Answered by Wayne Bloss on December 23, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP