question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blacklist nested attributes

See original GitHub issue

Assuming my store objects looks like this { data: {search: {data: [....]}, history:{search: [...], product: [...]}, favourites: {search: [...], product: [...]}}, navigation: {....}, user: {....}}

How can I blacklist data.search, while keeping data.history and data.favourites ? I’ve tried with['data.search'], but no luck.

Thank you.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:29
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

13reactions
Venryxcommented, Mar 18, 2019

Here’s a slightly more modular version of @gyosifov’s solution above:

import omit from 'lodash/omit';

const blacklistPaths = ['prop1', 'prop2', 'prop3.nestedProp'];
const persistConfig = {
	[...]
	blacklist: blacklistPaths.filter(a => !a.includes('.')),
	transforms: [
		// nested blacklist-paths require a custom transform to be applied
		createTransform((inboundState, key) => {
			const blacklistPaths_forKey = blacklistPaths.filter(path => path.startsWith(`${key}.`)).map(path => path.substr(key.length + 1));
			return omit(inboundState, ...blacklistPaths_forKey);
		}, null),
	],
};
9reactions
gyosifovcommented, Oct 8, 2018

As @brunolemos and @rt2zz have suggested the code looks something like this:

import omit from 'lodash/omit'

let blacklistTransform = createTransform(
    (inboundState, key) => {
        if (key === 'data') {
            return omit(inboundState, ['search']);
        } else {
            return inboundState;
        }
    }
)
...
const persistConfig = {
    key: 'root',
    storage,
    transforms: [blacklistTransform],
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make redux-persist blacklist for nested state?
I understand that if I want to remove tracking completely, I will need to write blacklist: ['tracking'] inside persistConfig , but I'm not...
Read more >
List of blacklisted event attributes
Download scientific diagram | List of blacklisted event attributes from ... Malicious properties of DOM and resultant attack exploitation description.
Read more >
[SOLVED] Passing variables in nested loops
Hello, I would like to filter rows of a table using a blacklist. The structure of the blacklist is one column containing the...
Read more >
Configure the blacklist for views and reports
Groups included in the blacklist are indicated with a blacklist icon in the resource view of the ARM application. Their members are not...
Read more >
bmatei/stylelint-config NPM
Selector · selector-attribute-operator-blacklist - disabled since we don't have anything to blacklist · selector-attribute-operator-whitelist - disabled since we ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found