File tree 1 file changed +17
-0
lines changed 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,23 @@ const store = configureStore({
39
39
export type RootState = ReturnType <typeof store .getState >
40
40
` ` `
41
41
42
+ Note that passing the reducers directly is not recommended when you need to add custom middleware,
43
+ because this can cause a circular reference in TypeScript:
44
+
45
+ ` ` ` typescript
46
+ import { configureStore } from ' @reduxjs/toolkit'
47
+ import rootReducer from ' ./rootReducer'
48
+ const store = configureStore ({
49
+ reducer: rootReducer ,
50
+ middleware: [
51
+ ... customMiddleware ,
52
+ ... getDefaultMiddleware <RootState >(),
53
+ ] as const ,
54
+ })
55
+ // TS2456: Type alias 'RootState' circularly references itself.
56
+ export type RootState = ReturnType <typeof store .getState >
57
+ ` ` `
58
+
42
59
### Getting the ` Dispatch ` type
43
60
44
61
If you want to get the ` Dispatch ` type from your store, you can extract it after creating the store.
You can’t perform that action at this time.
0 commit comments