rt2zz/redux-persist

Changes to the store are not applying

rochijacob opened this issue · 5 comments

I am changing some things in the reducer yet the changes are not visible. The previous reducer persists. Eventhough I reset my application my changes to the reducer never apply.

This is mi store.js, where I set the redux persist configuration:

import { configureStore } from '@reduxjs/toolkit';
import { FLUSH, PAUSE, PERSIST, persistReducer, persistStore, PURGE, REGISTER, REHYDRATE } from 'redux-persist';
import { combineReducers } from 'redux';
import AsyncStorage from '@react-native-async-storage/async-storage';

//Reducers
import loaderReducer from './loader';
import userReducer from './user';
import dataSlice from './data';

const rootReducer = combineReducers({loader: loaderReducer, userInfo: userReducer, data: dataSlice});

//Persist Config

const persistConfig = {
  key: 'root',
  version: 11, //Increment this value to reset the storage
  storage: AsyncStorage,
  blacklist: ['sedes'], //No se persisten estos reducers
};

const persistedReducer = persistReducer(persistConfig, rootReducer);

const store = configureStore({  
  reducer: persistedReducer, 
  middleware: getDefaultMiddleware => getDefaultMiddleware({
    inmutableCheck: {warnAfter: 123}, 
    serializableCheck: {
      ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER], //No se chequean estos tipos de acciones
      warnAfter: 124,
    } 
  })});

export const persistor = persistStore(store);
export default store;

and this is an example of a store:

import { createSlice } from "@reduxjs/toolkit";

const initialState = {
    load: false
}

export const loaderSlice = createSlice({
    name: "loader",
    initialState,
    reducers: {
        setLoader: (state, action) => {
            state.load = action.payload;
        }
    }
})

export const {setLoader} = loaderSlice.actions

export default loaderSlice.reducer

I am changing the version in the persistConfig (as this was an error I had in a previous proyect) yet there is no change at all. I am thinking maybe I am missing some import or importing something wrongly. Asi this EXACT configuration works perfectly in another proyect (maybe because I had a lower version of redux-persist)

Same problem here. I'm getting an old state from rehydration.
(Note: I'm not getting initial state; I'm getting some old state. New changes to the state are not persisted.)

Same problem here.

I am reseting persisted state when user logout.
And after login my redux state updates, but after i refresh the app state is not persisted.

Steps:

  • Login
  • Do any action or anything in app (State updates and persisted also)
  • Close and open app again (Getting persisted state)
  • Logout (State resets in after this step)
  • Login
  • Do any action or anything in app (State updates)
  • Close and open app again (Not getting persisted state, getting empty state at this point)
Mura7 commented

+1

Same issue

Same issue here