Files
Checkmate/client/src/store.js
T

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-06-20 14:07:33 -07:00
import { configureStore, combineReducers } from "@reduxjs/toolkit";
2024-07-30 11:25:14 -07:00
2024-06-07 16:17:10 -07:00
import authReducer from "./Features/Auth/authSlice";
2024-08-20 17:10:03 -04:00
import uiReducer from "./Features/UI/uiSlice";
2024-06-20 14:07:33 -07:00
import storage from "redux-persist/lib/storage";
import { persistReducer, persistStore, createTransform } from "redux-persist";
const authTransform = createTransform(
(inboundState) => {
const { profileImage, ...rest } = inboundState;
return rest;
},
// No transformation on rehydration
null,
// Only applies to auth
{ whitelist: ["auth"] }
);
2024-06-20 14:07:33 -07:00
const persistConfig = {
key: "root",
storage,
2025-06-13 10:00:48 +08:00
whitelist: ["auth", "ui"],
transforms: [authTransform],
2024-06-20 14:07:33 -07:00
};
const rootReducer = combineReducers({
auth: authReducer,
ui: uiReducer,
});
2024-06-20 14:07:33 -07:00
const persistedReducer = persistReducer(persistConfig, rootReducer);
export const store = configureStore({
reducer: persistedReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: {
ignoredActions: ["persist/PERSIST", "persist/REHYDRATE", "persist/REGISTER"],
},
}),
2024-06-20 14:07:33 -07:00
});
export const persistor = persistStore(store);
2024-09-27 12:13:39 +08:00
export default store;