Skip to content

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