store to ts
This commit is contained in:
1 parent
f38b305ba7
commit
85dbe34e00
2 files changed
+17
-10
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ import App from "./App.jsx";
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
import { BrowserRouter as Router } from "react-router-dom";
|
import { BrowserRouter as Router } from "react-router-dom";
|
||||||
import { Provider } from "react-redux";
|
import { Provider } from "react-redux";
|
||||||
import { persistor, store } from "./store.js";
|
import { persistor, store } from "@/store.js";
|
||||||
import { PersistGate } from "redux-persist/integration/react";
|
import { PersistGate } from "redux-persist/integration/react";
|
||||||
import I18nLoader from "./Components/v1/I18nLoader/index.jsx";
|
import I18nLoader from "./Components/v1/I18nLoader/index.jsx";
|
||||||
import { initApiClient } from "./Utils/ApiClient.js";
|
import { initApiClient } from "./Utils/ApiClient.js";
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
import { configureStore, combineReducers } from "@reduxjs/toolkit";
|
import { configureStore, combineReducers } from "@reduxjs/toolkit";
|
||||||
|
import authReducer from "@/Features/Auth/authSlice";
|
||||||
import authReducer from "./Features/Auth/authSlice";
|
import uiReducer from "@/Features/UI/uiSlice";
|
||||||
import uiReducer from "./Features/UI/uiSlice";
|
|
||||||
import storage from "redux-persist/lib/storage";
|
import storage from "redux-persist/lib/storage";
|
||||||
import { persistReducer, persistStore, createTransform } from "redux-persist";
|
import {
|
||||||
|
persistReducer,
|
||||||
|
persistStore,
|
||||||
|
createTransform,
|
||||||
|
PERSIST,
|
||||||
|
REHYDRATE,
|
||||||
|
} from "redux-persist";
|
||||||
|
|
||||||
const authTransform = createTransform(
|
const authTransform = createTransform(
|
||||||
(inboundState) => {
|
(inboundState: Record<string, unknown>) => {
|
||||||
const { profileImage, ...rest } = inboundState;
|
const { profileImage, ...rest } = inboundState;
|
||||||
return rest;
|
return rest;
|
||||||
},
|
},
|
||||||
// No transformation on rehydration
|
undefined,
|
||||||
null,
|
|
||||||
// Only applies to auth
|
|
||||||
{ whitelist: ["auth"] }
|
{ whitelist: ["auth"] }
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -28,6 +31,7 @@ const rootReducer = combineReducers({
|
|||||||
ui: uiReducer,
|
ui: uiReducer,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// @ts-expect-error - redux-persist types don't align perfectly with redux-toolkit
|
||||||
const persistedReducer = persistReducer(persistConfig, rootReducer);
|
const persistedReducer = persistReducer(persistConfig, rootReducer);
|
||||||
|
|
||||||
export const store = configureStore({
|
export const store = configureStore({
|
||||||
@@ -35,10 +39,13 @@ export const store = configureStore({
|
|||||||
middleware: (getDefaultMiddleware) =>
|
middleware: (getDefaultMiddleware) =>
|
||||||
getDefaultMiddleware({
|
getDefaultMiddleware({
|
||||||
serializableCheck: {
|
serializableCheck: {
|
||||||
ignoredActions: ["persist/PERSIST", "persist/REHYDRATE", "persist/REGISTER"],
|
ignoredActions: [PERSIST, REHYDRATE, "persist/REGISTER"],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export type RootState = ReturnType<typeof rootReducer>;
|
||||||
|
export type AppDispatch = typeof store.dispatch;
|
||||||
|
|
||||||
export const persistor = persistStore(store);
|
export const persistor = persistStore(store);
|
||||||
export default store;
|
export default store;
|
||||||
Reference in new issue
Block a user