-
Notifications
You must be signed in to change notification settings - Fork 862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blacklist nested attributes #134
Comments
This is not available out of the box but it should be trivial to write a transform that does that. It would look something like let blacklistTransform = createTransform(
(inboundState, key) => {
if (key !== 'data') return inboundState
else return {
...inboundState,
data: undefined,
}
}
) |
while I have not personally used it, this project aims to solve this problem: https://github.com/edy/redux-persist-transform-filter |
There is one more way. Store a getter function in place of nested key which needs to be blacklisted. let nestedKey = "blacklisted"; In storage getter function will always be null. When passing as props call the getter function to get the actual value. |
As @brunolemos and @rt2zz have suggested the code looks something like this:
|
Here's a slightly more modular version of @gyosifov's solution above:
|
Has anyone come up with a better solution so far? |
@Venryx Works well, thank you :) |
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 keepingdata.history
anddata.favourites
?I've tried with
['data.search']
, but no luck.Thank you.
The text was updated successfully, but these errors were encountered: