Closed modosc closed 6 years ago
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.
Please reopen if this is still an issue for you.
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 thenew CookieStorage()
instantiation or as part of the options passed tocreatePersistor
fromredux-persist
.if i set
keyPrefix
increatePersistor
then i can't get the custom expiration logic here to work correctly.consider a reducer
foo
- ifkeyPrefix='_'
increatePersistor
then theCookieStorage
's(get|set|remove)Item
methods will all be called with_foo
as the key instead offoo
.if i set
keyPrefix
in theCookieStorage
(and not increatePersistor
) things still don't work correctly becauseredux-persit
will set a default prefix of reduxPersist: which still breaks this logic.