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

Fixed incorrect slicing when slice is 0 or null #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixed incorrect slicing when slice is 0 or null #63

wants to merge 1 commit into from

Conversation

electerious
Copy link

It's currently not possibly to save a path with the value 0 or null because the if returns false when obj[key] is 0 or null. Caused me a lot of headache.

I saw you're already working on v1.0, but I hope you're releasing this a bugfix for the current version. It's causing a lot of trouble in my application.

Thanks!

It's currently not possibly to save a path with the value `0` because the if returns `false` when `obj[key]` is `0`. Caused me a lot of headache.
@johndturn
Copy link

@elgerlambert Any idea on when this should be fixed and pushed out? Until that point, this is a blocker for me to use this in my application. Otherwise, it works really well!

@giannif
Copy link

giannif commented Mar 14, 2017

@jdt1204 you can use a custom slicer passed to persistState in the meantime

const slicer = paths => state => {
    const subset = {}
    paths.forEach(path => {
        // default implementation does a falsy check on state[path],
        // which means false doesn't save hrmph
        subset[path] = state[path]
    })
    return subset
}

compose(applyMiddleware(...middleware), persistState(localStorageProps, { slicer }), devTools)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants