You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alternately,youmaypassacallbackfunction that will receive `getDefaultMiddleware` as its argument,
93
-
and should return a middleware array. This lets you skip importing `getDefaultMiddleware` separately. If using TypeScript, prefer using this syntax, as we provide a more strongly-typed version of `getDefaultMiddleware` that will correctly
94
-
retain the types of the provided middleware when constructing the store.
Copy file name to clipboardExpand all lines: docs/api/getDefaultMiddleware.mdx
-23Lines changed: 0 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,29 +64,6 @@ const store = configureStore({
64
64
65
65
It is preferrable to use the chainable `.concat(...)` and `.prepend(...)` methods of the returned `MiddlewareArray` instead of the array spread operator, as the latter can lose valuable type information under some circumstances.
66
66
67
-
## getDefaultMiddleware import
68
-
69
-
While the callback notation with `configureStore` shown in the last example is the recommended way of using `getDefaultMiddleware`, it can also be imported to be used independently from 'configureStore':
The benefit of using the callback notation is that the `State` type is already pre-bound, which might prevent circular type references when trying to specify generics by hand.
Copy file name to clipboardExpand all lines: docs/usage/usage-guide.md
+21-17Lines changed: 21 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -139,7 +139,9 @@ export default function configureAppStore(preloadedState) {
139
139
}
140
140
```
141
141
142
-
If you provide the `middleware` argument, `configureStore` will only use whatever middleware you've listed. If you want to have some custom middleware _and_ the defaults all together, you can call [`getDefaultMiddleware`](../api/getDefaultMiddleware.mdx) and include the results in the `middleware` array you provide.
142
+
If you provide the `middleware` argument, `configureStore` will only use whatever middleware you've listed.
143
+
If you want to have some custom middleware _and_ the defaults all together, you can use the callback notation,
144
+
call [`getDefaultMiddleware`](../api/getDefaultMiddleware.mdx) and include the results in the `middleware` array you return.
143
145
144
146
## Writing Reducers
145
147
@@ -1033,16 +1035,17 @@ The [serializability dev check middleware](../api/serializabilityMiddleware.mdx)
Copy file name to clipboardExpand all lines: docs/usage/usage-with-typescript.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,8 +89,6 @@ The type of the `dispatch` function type will be directly inferred from the `mid
89
89
90
90
As TypeScript often widens array types when combining arrays using the spread operator, we suggest using the `.concat(...)` and `.prepend(...)` methods of the `MiddlewareArray` returned by `getDefaultMiddleware()`.
91
91
92
-
Also, we suggest using the callback notation for the `middleware` option to get a correctly pre-typed version of `getDefaultMiddleware` that does not require you to specify any generics by hand.
0 commit comments