I have the following:
import AsyncStorage from '@react-native-async-storage/async-storage'
import { persistStore, persistReducer } from 'redux-persist';
import { configureStore } from "@reduxjs/toolkit";
import { searchReducer } from "./search/searchSlice"
import { userReducer } from "./user/userSlice"
export const store = configureStore({
reducer: {
search: searchReducer,
user: userReducer
}
})
export type RootState = ReturnType<typeof store.getState>
export type AppDispatch = typeof store.dispatch
I need to persist only the user reducer. How can I do it since there isn't any definition of a 'user' reducer outside the configureStore function? What should be in the place in the "???" below?
const persistedReducer = persistReducer({
key: "root",
storage: AsyncStorage,
whitelist: [???]
}, ???)
export const persistor = persistStore(store)
You can do as following.