redux-persist icon indicating copy to clipboard operation
redux-persist copied to clipboard

Redux persist getting cleared after persisting PatientsReducers

Open anuragkaushik10 opened this issue 1 year ago • 0 comments

Here I am trying to persist PatientsReducer as well as AuthReducer.

When doing just for AuthReducer it is working as expected. But when including PatientsReducer in the whitelist array the whole redux store is getting cleared.

Here's my Store.ts

import AsyncStorage from '@react-native-async-storage/async-storage';
import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit';
import { persistReducer, persistStore } from 'redux-persist';

import rootReducer from './store-config/StoreConfig';

const persistConfig = {
  key: 'root',
  storage: AsyncStorage,
  whitelist: ['auth', 'patients'],
};

const persistedReducer = persistReducer(persistConfig, rootReducer);

const store = configureStore({
  middleware: getDefaultMiddleware({
    serializableCheck: false,
  }),
  reducer: persistedReducer,
});

const persistor = persistStore(store);

export { store, persistor };

export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

Any help is highly appreciated.

anuragkaushik10 avatar Apr 27 '24 10:04 anuragkaushik10