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

Apply slicerFn in store enhancer to filter paths on store initialization #69

Open
giannif opened this issue Mar 14, 2017 · 0 comments
Open

Comments

@giannif
Copy link

giannif commented Mar 14, 2017

I'm using paths to store pieces of my state. The paths I specify don't influence the initial state, they only affect what's stored after the state changes.

I'd expect my store to only to get paths from redux localStorage that I specify when creating the store

On page one, I use path "A"

compose(applyMiddleware(...middleware), persistState(["A"], { slicer }), devTools)

On page two, I use path "B"

compose(applyMiddleware(...middleware), persistState(["B"], { slicer }), devTools)

If I first land on page one, and then go to page two, "A" will be in my state even though it's not in my paths.

When I leave page two, "A" will be removed, and "B" will persist, but I was expecting to not get "A" on page two at all

If the slicer was applied to persistedState in this persistState.js, it'd fix this issue:

const slicerFn = slicer(paths)
persistedState = slicerFn(deserialize(localStorage.getItem(key)))

I could submit a PR if you're merging those :) Or if this was done intentionally, lmk

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

No branches or pull requests

1 participant