-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.ts
25 lines (18 loc) · 632 Bytes
/
store.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { combineReducers, configureStore, Action } from "@reduxjs/toolkit";
import authReducer from "@/slices/authSlice";
import { APP_LOGOUT } from "./utils/constants";
const appReducer = combineReducers({
[authReducer.name]: authReducer.reducer,
});
const rootReducer = (state: any, action: Action) => {
if (action?.type === APP_LOGOUT) {
state = {};
}
return appReducer(state, action);
};
export const store = configureStore({
reducer: rootReducer,
devTools: process.env.NODE_ENV !== "production",
});
export type RootState = ReturnType<typeof appReducer>;
export type AppDispatch = typeof store.dispatch;