-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstore.ts
32 lines (26 loc) · 945 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
26
27
28
29
30
31
32
import { configureStore, ThunkAction, Action } from '@reduxjs/toolkit';
import storage from 'redux-persist/lib/storage';
import { combineReducers } from 'redux';
import { persistReducer } from 'redux-persist';
import thunk from 'redux-thunk';
import authReducer from 'features/auth-slice';
import menuReducer from 'features/menu-slice';
const reducers = combineReducers({
auth: authReducer,
menu: menuReducer,
});
const persistConfig = {
key: 'root',
storage,
whitelist: ['auth', 'menu'],
};
const persistedReducer = persistReducer(persistConfig, reducers);
const store = configureStore({
reducer: persistedReducer,
devTools: process.env.NODE_ENV !== 'production',
middleware: [thunk],
});
export default store;
export type AppDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;
export type AppThunk<ReturnType = void> = ThunkAction<ReturnType, RootState, unknown, Action<string>>;