Closed zhangwei900808 closed 5 years ago
You need to pass autoExpire: true
as an option to the expireReducer
. Try changing the expireReducer
options to be like below
expireReducer('authReducer', {
expireSeconds: 10,
autoExpire: true
})
@kamranahmedse thanks your resolve my problem :) but when I used encryptor that localstorage data is error and while you refresh the brower is always lost authReducer ,you can see below code
import createEncryptor from "redux-persist-transform-encrypt";
import expireReducer from "redux-persist-expire";
const encryptor = createEncryptor({
secretKey: "hiynn",
onError: function(error) {}
});
const expireTransform = expireReducer("authReducer", {
expireSeconds: 10,
expiredState: {},
autoExpire: true
});
const persistConfig = {
transforms: [
encryptor,
expireTransform
],
key: config.persist,
storage,
version: 2,
migrate: createMigrate(migrations, { debug: false })
};
I used redux-persist-expire,but when I refresh the localstorage it did not work ,which is wrong!