kamranahmedse / redux-persist-expire

Expiring transformer for redux-persist
MIT License
78 stars 12 forks source link

Doesn't seem to work #17

Open trybick opened 4 years ago

trybick commented 4 years ago

Can you spot something I'm doing wrong? I have two reducers and am adding expireReducer to the rootConfig.

const userPersistConfig = {
  key: 'user',
  storage,
  blacklist: ['hasLocalWarningToastBeenShown'],
};

const tvPersistConfig = {
  key: 'tv',
  storage,
};

const rootPersistConfig = {
  key: 'root',
  storage,
  blacklist: ['user'],
  transforms: [
    expireReducer('tv', {   // expire here!
      expireSeconds: 10,
      autoExpire: true,
    }),
  ],
};

const rootReducer = combineReducers({
  user: persistReducer(userPersistConfig, userReducer),
  tv: persistReducer(tvPersistConfig, tvReducer),
});

const persistedReducer = persistReducer(rootPersistConfig, rootReducer);
mathe-matician commented 3 years ago

@trybick I was having a similar problem. It might be worth noting that I thought that seconds might actually be milliseconds, so I tried 10000, and it still did not work. I ended up using redux-persist-transform-expire-in, which worked perfectly in my case (and note that it uses milliseconds if you use it).

appkery commented 1 year ago

It works very well. See #33. You should have used a key inside of root.