29 lines
837 B
TypeScript
29 lines
837 B
TypeScript
import { configureStore } from "@reduxjs/toolkit";
|
|
import { useDispatch } from "react-redux";
|
|
import { persistReducer, persistStore } from "redux-persist";
|
|
import storage from "redux-persist/lib/storage";
|
|
import rootReducer from "@/lib/features/rootReducer";
|
|
|
|
const persistConfig = {
|
|
key: "root",
|
|
storage,
|
|
whitelist: ["targetService"],
|
|
};
|
|
|
|
const persistedReducer = persistReducer(persistConfig, rootReducer);
|
|
|
|
export const store = configureStore({
|
|
reducer: persistedReducer,
|
|
middleware: getDefaultMiddleware =>
|
|
getDefaultMiddleware({
|
|
serializableCheck: false,
|
|
}),
|
|
});
|
|
|
|
export const persistor = persistStore(store);
|
|
|
|
export type RootState = ReturnType<typeof store.getState>;
|
|
export type AppDispatch = typeof store.dispatch;
|
|
|
|
export const useAppDispatch = () => useDispatch<AppDispatch>();
|