AnswerBun.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!

Related Questions

How to toggle button text when clicked with JavaScript in HTML

6  Asked on December 21, 2020 by marcosvaldez81

     

Why is getDate() a month off?

3  Asked on December 21, 2020 by aztheog

   

Using GLOB to match each character in an SQLite TEXT field

2  Asked on December 21, 2020 by anagramdatagram

   

Timeout on a function call

18  Asked on December 21, 2020 by teifion

       

How can I access a variable inside a nested array?

2  Asked on December 21, 2020 by intelltanito

   

OkHttpClient doesn’t add headers to requests

2  Asked on December 21, 2020 by ghaylen

         

Can someone teach me how to get this output

2  Asked on December 20, 2020 by surtz

 

Match multiple exact routes

3  Asked on December 20, 2020 by magofoco

   

Return a 0 if no rows are found in Microsoft SQL Server

2  Asked on December 20, 2020 by henk-hadders

     

What’s the good way to pass data to a thread in c++?

4  Asked on December 20, 2020 by ting-wang

   

Firestore query single document

2  Asked on December 20, 2020 by zvi-karp

     

Expand nested arrays postgres

1  Asked on December 20, 2020 by dan-wolchonok

         

grpc python measure response time

1  Asked on December 20, 2020 by user3599803

     

gtkmm load from resource plain text file

1  Asked on December 19, 2020 by tophyd-ayur

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP