File tree 1 file changed +8
-3
lines changed
services/common/src/redux
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { sharedReducer } from "@mds/common/redux/reducers/rootReducerShared" ;
2
- import { configureStore } from "@reduxjs/toolkit" ;
2
+ import { configureStore , Dispatch } from "@reduxjs/toolkit" ;
3
3
import { loadingBarReducer } from "react-redux-loading-bar" ;
4
4
5
5
import type { TypedUseSelectorHook } from 'react-redux'
6
6
import { useDispatch , useSelector , useStore } from 'react-redux'
7
+ import type { FormAction } from 'redux-form' ;
7
8
8
9
export const getStore = ( preloadedState = { } ) =>
9
10
configureStore ( {
@@ -17,10 +18,14 @@ export const getStore = (preloadedState = {}) =>
17
18
18
19
export const store = getStore ( ) ;
19
20
20
- // Provide typed versions for global redux functions
21
+ /**
22
+ * Provide typed versions for global redux functions
23
+ **/
24
+
21
25
type RootState = ReturnType < typeof store . getState > ;
22
26
23
- export type AppDispatch = typeof store . dispatch ;
27
+ // Infer the `RootState` and `AppDispatch` types from the store itself + make sure redux-form actions are captured as well.
28
+ export type AppDispatch = typeof store . dispatch & Dispatch < FormAction > ;
24
29
export type AppStore = typeof store ;
25
30
26
31
// Use throughout your app instead of plain `useDispatch` and `useSelector`
You can’t perform that action at this time.
0 commit comments