Skip to content

Commit 3b1fbf3

Browse files
committed
Merge branch 'master' of https://github.com/reduxjs/redux-toolkit into update-ci-actions
2 parents 14be7a2 + 95c4cbc commit 3b1fbf3

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

docs/api/configureStore.mdx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,15 @@ An optional initial state value to be passed to the Redux `createStore` function
154154

155155
### `enhancers`
156156

157-
An optional array of Redux store enhancers, or a callback function to customize the array of enhancers.
157+
A callback function to customize the array of enhancers.
158158

159-
If defined as an array, these will be passed to [the Redux `compose` function](https://redux.js.org/api/compose), and the combined enhancer will be passed to `createStore`.
159+
Enhancers returned by this callback will be passed to [the Redux `compose` function](https://redux.js.org/api/compose), and the combined enhancer will be passed to `createStore`.
160160

161161
:::tip Dev Tools
162162
This should _not_ include the Redux DevTools Extension `composeWithDevTools`, as this is already handled by `configureStore`.
163163

164-
Example: `enhancers: new Tuple(offline)` will result in a final setup of `[offline, devToolsExtension]`.
164+
Example: `enhancers: () => new Tuple(offline)` will result in a final setup of `[offline, devToolsExtension]`.
165+
:::
165166

166167
If not provided, `configureStore` will call `getDefaultEnhancers` and use the array of enhancers it returns (including `applyMiddleware` with specified middleware).
167168

@@ -174,7 +175,7 @@ For more details on how the `enhancer` parameter works and the list of enhancers
174175
175176
:::caution Middleware
176177
177-
If you provide an array, this `applyMiddleware` enhancer will _not_ be used.
178+
If you don't use `getDefaultEnhancers` and instead return an array, the `applyMiddleware` enhancer will _not_ be used.
178179
179180
`configureStore` will warn in console if any middleware are provided (or left as default) but not included in the final list of enhancers.
180181
@@ -196,23 +197,24 @@ configureStore({
196197
configureStore({
197198
reducer,
198199
middleware: () => [],
199-
enhancers: () => [offline(offlineConfig)],
200+
enhancers: () => [offline(offlineConfig)],
200201
})
201202
```
202203

204+
Note that if using Typescript, the `middleware` option is required to be provided _before_ the enhancer option, as the type of `getDefaultEnhancers` depends on its result.
205+
203206
:::
204207

205208
:::note Tuple
206209
Typescript users are required to use a `Tuple` instance (if not using a `getDefaultEnhancer` result, which is already a `Tuple`), for better inference.
207210

208-
```
211+
```ts no-transpile
209212
import { configureStore, Tuple } from '@reduxjs/toolkit'
210213

211214
configureStore({
212-
reducer: rootReducer,
213-
enhancers: () => new Tuple(offline),
215+
reducer: rootReducer,
216+
enhancers: () => new Tuple(offline),
214217
})
215-
216218
```
217219
218220
Javascript-only users are free to use a plain array if preferred.

docs/api/getDefaultEnhancers.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ If you want to customise the list of enhancers, you can supply an array of enhan
2828
```js
2929
const store = configureStore({
3030
reducer: rootReducer,
31-
enhancers: [offline(offlineConfig)],
31+
enhancers: () => new Tuple(offline(offlineConfig)),
3232
})
3333

3434
// store specifically has the offline enhancer applied

docs/rtk-query/api/created-api/hooks.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ type UseQueryResult<T> = {
277277
isSuccess: boolean // Query has data from a successful load.
278278
isError: boolean // Query is currently in an "error" state.
279279

280-
refetch: () => void // A function to force refetch the query
280+
refetch: () => QueryActionCreatorResult // A function to force refetch the query - returns a Promise with additional methods
281281
}
282282
```
283283

0 commit comments

Comments
 (0)