kamranahmedse / redux-persist-expire

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

Does not work with nested persists? #5

Open justduy opened 5 years ago

justduy commented 5 years ago

Does not seem to work with nested persists, the tags state in TagsReducer still retains the data after 10 seconds.

import storageSession from "redux-persist/lib/storage/session";
import storageLocal from "redux-persist/lib/storage";
import autoMergeLevel2 from "redux-persist/lib/stateReconciler/autoMergeLevel2";
import { combineReducers } from "redux";
import { persistReducer } from "redux-persist";
import expireReducer from "redux-persist-expire";

import auth from "./authReducer";
import TagsReducer from "./api/tagsReducer";

const tagsStorePersistConfig = {
    key: "tagsStore",
    storage: storageLocal,
    stateReconciler: autoMergeLevel2,
    whitelist: ["tags"],
    transforms: [
        expireReducer("tags", {
            expireSeconds: 10,
            expiredState: []
        })
    ]
};

const rootReducer = combineReducers({
    auth,
    tagsStore: persistReducer(tagsStorePersistConfig, TagsReducer)
});

export default rootReducer;
BenBach commented 5 years ago

@justduy Did you find a solution? Would appreciate any help

justduy commented 5 years ago

@BenBach could not find any solutions to this, have give up on making it work. You could clear the storage yourself programmatically by doing the check manually.

maicolsantos commented 2 years ago

Guys, I solved this error using autoExpire true and setting espiredState like my redux initial state