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
In order to use slice creators, `reducers` becomes a callback, which receives a `create` object. This `create` object contains a couple of [inbuilt creators](#rtk-creators), along with any creators passed to [`buildCreateSlice`](#buildcreateslice).
49
+
In order to use slice creators, `reducers` becomes a callback, which receives a `create` object. This `create` object contains a couple of [inbuilt creators](#rtk-creators), along with any creators passed to [`buildCreateSlice`](../api/createSlice#buildcreateslice).
@@ -135,11 +135,11 @@ The [creator definition](#creator-definitions) for `create.reducer` is exported
135
135
136
136
#### `create.preparedReducer`
137
137
138
-
A [prepared](#customizing-generated-action-creators) reducer, to customize the action creator. Creates a prepared action creator with the same name as the reducer.
138
+
A [prepared](../api/createSlice#customizing-generated-action-creators) reducer, to customize the action creator. Creates a prepared action creator with the same name as the reducer.
139
139
140
140
**Parameters**
141
141
142
-
-**prepareAction** The [`prepare callback`](./createAction#using-prepare-callbacks-to-customize-action-contents).
142
+
-**prepareAction** The [`prepare callback`](../api/createAction#using-prepare-callbacks-to-customize-action-contents).
143
143
-**reducer** The slice case reducer to use.
144
144
145
145
The action passed to the case reducer will be inferred from the prepare callback's return.
@@ -164,7 +164,7 @@ The [creator definition](#creator-definitions) for `create.preparedReducer` is e
164
164
165
165
### Optional RTK Creators
166
166
167
-
These creators are not included in the default `create` object, but can be added by passing them to [`buildCreateSlice`](#buildcreateslice).
167
+
These creators are not included in the default `create` object, but can be added by passing them to [`buildCreateSlice`](../api/createSlice#buildcreateslice).
168
168
169
169
The name the creator is available under is based on the key used when calling `buildCreateSlice`. For example, to use `create.asyncThunk`:
170
170
@@ -235,14 +235,14 @@ Creates an async thunk and adds any provided case reducers for lifecycle actions
235
235
236
236
**Parameters**
237
237
238
-
-**payloadCreator** The thunk [payload creator](./createAsyncThunk#payloadcreator).
238
+
-**payloadCreator** The thunk [payload creator](../api/createAsyncThunk#payloadcreator).
239
239
-**config** The configuration object. (optional)
240
240
241
-
The configuration object can contain case reducers for each of the [lifecycle actions](./createAsyncThunk#promise-lifecycle-actions) (`pending`, `fulfilled`, and `rejected`), as well as a `settled` reducer that will run for both fulfilled and rejected actions (note that this will run _after_ any provided `fulfilled`/`rejected` reducers. Conceptually it can be thought of like a `finally` block.).
241
+
The configuration object can contain case reducers for each of the [lifecycle actions](../api/createAsyncThunk#promise-lifecycle-actions) (`pending`, `fulfilled`, and `rejected`), as well as a `settled` reducer that will run for both fulfilled and rejected actions (note that this will run _after_ any provided `fulfilled`/`rejected` reducers. Conceptually it can be thought of like a `finally` block.).
242
242
243
243
Each case reducer will be attached to the slice's `caseReducers` object, e.g. `slice.caseReducers.fetchTodo.fulfilled`.
244
244
245
-
The configuration object can also contain [`options`](./createAsyncThunk#options).
245
+
The configuration object can also contain [`options`](../api/createAsyncThunk#options).
246
246
247
247
```ts no-transpile
248
248
create.asyncThunk(
@@ -272,7 +272,7 @@ create.asyncThunk(
272
272
273
273
:::note
274
274
275
-
Typing for `create.asyncThunk` works in the same way as [`createAsyncThunk`](../usage/usage-with-typescript#createasyncthunk), with one key difference.
275
+
Typing for `create.asyncThunk` works in the same way as [`createAsyncThunk`](./usage-with-typescript#createasyncthunk), with one key difference.
276
276
277
277
A type for `state` and/or `dispatch`_cannot_ be provided as part of the `ThunkApiConfig`, as this would cause circular types.
For common thunk API configuration options, a [`withTypes` helper](../usage/usage-with-typescript#defining-a-pre-typed-createasyncthunk) is provided:
302
+
For common thunk API configuration options, a [`withTypes` helper](./usage-with-typescript#defining-a-pre-typed-createasyncthunk) is provided:
303
303
304
304
```ts no-transpile
305
305
reducers: (create) => {
@@ -365,7 +365,7 @@ Typically a creator will return a [single reducer definition](#single-definition
365
365
366
366
A creator definition contains the actual runtime logic for that creator. It's an object with a `type` property, a `create` method, and an optional `handle` method.
367
367
368
-
It's passed to [`buildCreateSlice`](#buildcreateslice) as part of the `creators` object, and the name used when calling `buildCreateSlice` will be the key the creator is nested under in the `create` object.
368
+
It's passed to [`buildCreateSlice`](../api/createSlice#buildcreateslice) as part of the `creators` object, and the name used when calling `buildCreateSlice` will be the key the creator is nested under in the `create` object.
The same as [`addCase`](./createReducer#builderaddcase) for `createReducer` and `extraReducers`. Adds a case reducer for a given action type, and can receive an action type string or an action creator with a `.type` property.
441
+
The same as [`addCase`](../api/createReducer#builderaddcase) for `createReducer` and `extraReducers`. Adds a case reducer for a given action type, and can receive an action type string or an action creator with a `.type` property.
The same as [`addMatcher`](./createReducer#builderaddmatcher) for `createReducer` and `extraReducers`. Adds a case reducer which will be called when a given matcher returns true.
450
+
The same as [`addMatcher`](../api/createReducer#builderaddmatcher) for `createReducer` and `extraReducers`. Adds a case reducer which will be called when a given matcher returns true.
451
451
452
452
```ts no-transpile
453
453
const matcher =isAnyOf(action, action2)
@@ -510,7 +510,7 @@ The type parameters for `SliceReducerCreators` are:
510
510
511
511
-`State` - The state type used by the slice.
512
512
-`CaseReducers` - The case reducer definitions returned by the creator callback.
513
-
-`Name` - The [`name`](#name) used by the slice.
513
+
-`Name` - The [`name`](../api/createSlice#name) used by the slice.
514
514
515
515
The `ReducerCreatorEntry<Create, Exposes>` utility has two type parameters:
A creator could also return multiple definitions, which would then be spread into the final definitions object. This is a more composable alternative to the [wrapping `createSlice`](usage/usage-with-typescript#wrapping-createslice) approach, as you could call multiple creators as needed.
903
+
A creator could also return multiple definitions, which would then be spread into the final definitions object. This is a more composable alternative to the [wrapping `createSlice`](./usage-with-typescript#wrapping-createslice) approach, as you could call multiple creators as needed.
904
904
905
905
One example could be returning some pagination related reducers.
0 commit comments