Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit ac4fb14

Browse files
committed
add: store for redux
1 parent ce8f38c commit ac4fb14

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/redux/hooks.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux';
2+
3+
import type { AppDispatch, RootState } from './store';
4+
5+
export const useAppDispatch: () => AppDispatch = useDispatch;
6+
7+
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;

src/redux/rootReducer.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import giftReducer from '../features/gifts/giftSlice';
2+
import recipientReducer from '../features/recipients/recipientSlice';
3+
import { combineReducers } from '@reduxjs/toolkit';
4+
5+
const rootReducer = combineReducers({
6+
gifts: giftReducer,
7+
recipients: recipientReducer,
8+
});
9+
10+
export default rootReducer;

src/redux/store.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { configureStore } from '@reduxjs/toolkit';
2+
3+
import rootReducer from './rootReducer';
4+
5+
const store = configureStore({
6+
reducer: rootReducer,
7+
});
8+
9+
export type RootState = ReturnType<typeof store.getState>;
10+
export type AppDispatch = typeof store.dispatch;
11+
12+
export default store;

0 commit comments

Comments
 (0)