Added and configured redux-persist
This commit is contained in:
1 parent
085c036bba
commit
5d855157b4
4 files changed
+51
-11
No files matched your search
+29
-3
@@ -1,7 +1,33 @@
|
||||
import { configureStore } from "@reduxjs/toolkit";
|
||||
import { configureStore, combineReducers } from "@reduxjs/toolkit";
|
||||
import monitorsReducer from "./Features/Monitors/monitorsSlice";
|
||||
import authReducer from "./Features/Auth/authSlice";
|
||||
import storage from "redux-persist/lib/storage";
|
||||
import { persistReducer, persistStore } from "redux-persist";
|
||||
|
||||
export default configureStore({
|
||||
reducer: { monitors: monitorsReducer, auth: authReducer },
|
||||
const persistConfig = {
|
||||
key: "root",
|
||||
storage,
|
||||
};
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
monitors: monitorsReducer,
|
||||
auth: authReducer,
|
||||
});
|
||||
|
||||
const persistedReducer = persistReducer(persistConfig, rootReducer);
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: persistedReducer,
|
||||
middleware: (getDefaultMiddleware) =>
|
||||
getDefaultMiddleware({
|
||||
serializableCheck: {
|
||||
ignoredActions: [
|
||||
"persist/PERSIST",
|
||||
"persist/REHYDRATE",
|
||||
"persist/REGISTER",
|
||||
],
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
export const persistor = persistStore(store);
|
||||
Reference in new issue
Block a user