Skip to content
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

boolean values not persisted #8

Open
adbs1 opened this issue Feb 22, 2021 · 2 comments
Open

boolean values not persisted #8

adbs1 opened this issue Feb 22, 2021 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@adbs1
Copy link

adbs1 commented Feb 22, 2021

Hi there,

Firstly, nice piece of work on this. Really simplifies things !!

I note that boolean properties are stripped from store state if they have a value of false. It happens in the following code; _pickBy is filtering any property with a falsy value, this of course includes any properties of type boolean with a value of false.

Was this intentional?

Cheers,
Andy

https://github.com/aspect-apps/redux-persist-machine/blob/master/lib/index.ts

/*
                 * Builds a state only containing the values
                 * we care about, which are defined in structure.
                 */
                const newState = _pickBy(state, (value: any, key: any) => {
                    /**
                     * If nothing is passed to the `values`
                     * parameter, all values will be used.
                     */
                    if (_isNil(stateValues)) return value;

                    if (stateValues.includes(key)) return value;
                });
@lukebrandonfarrell
Copy link
Owner

Hey @adbs1,

Thanks for raising the issue. This is in fact a bug, since you know the exact place it happens, do you have any ideas on how to address this in a PR ?

@lukebrandonfarrell lukebrandonfarrell added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Feb 22, 2021
@adbs1
Copy link
Author

adbs1 commented Feb 22, 2021

Okay, thanks. I'll hold off the PR for the moment as I think there are other issues. It should look something like this I believe:

const newState = _isNil(stateValues) ? state : _pick(state, Object.keys(stateValues));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants