forked from wednesday-solutions/next-bulletproof-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
22 lines (18 loc) · 886 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { configureStore } from "@reduxjs/toolkit";
import { useDispatch, TypedUseSelectorHook, useSelector } from "react-redux";
import repoReducer from "@slices/repos";
import { recommendationsApi } from "@features/repos/api/getRecommendations";
import { repoInfoApi } from "@features/info/api/getRepoInfo";
import middlewares from "./middlewares";
export const store = configureStore({
reducer: {
repos: repoReducer,
[recommendationsApi.reducerPath]: recommendationsApi.reducer,
[repoInfoApi.reducerPath]: repoInfoApi.reducer,
},
middleware: getDefaultMiddleware => getDefaultMiddleware().concat(middlewares),
});
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
export const useAppDispatch = () => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;