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

keyPrefix isn't handled right #4

Closed
modosc opened this issue Jan 19, 2017 · 2 comments
Closed

keyPrefix isn't handled right #4

modosc opened this issue Jan 19, 2017 · 2 comments
Assignees

Comments

@modosc
Copy link
Contributor

modosc commented Jan 19, 2017

i was in the middle of another pr when i found this - i'm not sure the best way forward.

it looks like there are two places to set keyPrefix, in the new CookieStorage() instantiation or as part of the options passed to createPersistor from redux-persist.

if i set keyPrefix in createPersistor then i can't get the custom expiration logic here to work correctly.

consider a reducer foo - if keyPrefix='_' in createPersistor then the CookieStorage's (get|set|remove)Item methods will all be called with _foo as the key instead of foo.

if i set keyPrefix in the CookieStorage (and not in createPersistor) things still don't work correctly because redux-persit will set a default prefix of reduxPersist: which still breaks this logic.

@abersager abersager self-assigned this Jan 25, 2017
@abersager
Copy link
Owner

abersager commented Jan 25, 2017

Hi, sorry for the late reply.

CookieStorage doesn't know about the prefix used by redux-persist. As you say, (get|set|remove)Item) methods get called with the prefix.

Therefore, if you'd like to use custom expiration for individual keys, you need to include the redux-persist provided prefix in the configuration. For instance, using default reduxPersist: prefix:

new CookieStorage({
  expiration: {
    default: null,
    "reduxPersist:foo": 600
  }
})

Could you try and see if this works for you? If so, I will update the example in the README to explain this properly.

@abersager abersager assigned modosc and unassigned abersager Jan 25, 2017
@abersager
Copy link
Owner

Please reopen if this is still an issue for you.

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

2 participants