Skip to content

Commit e310604

Browse files
committed
fix links
1 parent 7e60c5a commit e310604

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

docs/usage/custom-slice-creators.mdx

+14-14
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const { undo, redo, reset, updateTitle, togglePinned } =
4646

4747
## The `reducers` "creator callback" notation
4848

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`](#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).
5050

5151
```ts title="Creator callback for reducers"
5252
import { buildCreateSlice, asyncThunkCreator, nanoid } from '@reduxjs/toolkit'
@@ -135,11 +135,11 @@ The [creator definition](#creator-definitions) for `create.reducer` is exported
135135

136136
#### `create.preparedReducer`
137137

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.
139139

140140
**Parameters**
141141

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).
143143
- **reducer** The slice case reducer to use.
144144

145145
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
164164

165165
### Optional RTK Creators
166166

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).
168168

169169
The name the creator is available under is based on the key used when calling `buildCreateSlice`. For example, to use `create.asyncThunk`:
170170

@@ -235,14 +235,14 @@ Creates an async thunk and adds any provided case reducers for lifecycle actions
235235

236236
**Parameters**
237237

238-
- **payloadCreator** The thunk [payload creator](./createAsyncThunk#payloadcreator).
238+
- **payloadCreator** The thunk [payload creator](../api/createAsyncThunk#payloadcreator).
239239
- **config** The configuration object. (optional)
240240

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.).
242242

243243
Each case reducer will be attached to the slice's `caseReducers` object, e.g. `slice.caseReducers.fetchTodo.fulfilled`.
244244

245-
The configuration object can also contain [`options`](./createAsyncThunk#options).
245+
The configuration object can also contain [`options`](../api/createAsyncThunk#options).
246246

247247
```ts no-transpile
248248
create.asyncThunk(
@@ -272,7 +272,7 @@ create.asyncThunk(
272272

273273
:::note
274274

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.
276276

277277
A type for `state` and/or `dispatch` _cannot_ be provided as part of the `ThunkApiConfig`, as this would cause circular types.
278278

@@ -299,7 +299,7 @@ create.asyncThunk<Todo, string, { rejectValue: { error: string } }>(
299299
)
300300
```
301301

302-
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:
303303

304304
```ts no-transpile
305305
reducers: (create) => {
@@ -365,7 +365,7 @@ Typically a creator will return a [single reducer definition](#single-definition
365365

366366
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.
367367

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.
369369

370370
```ts no-transpile
371371
import { buildCreateSlice } from '@reduxjs/toolkit'
@@ -438,7 +438,7 @@ The context object includes:
438438

439439
#### `addCase`
440440

441-
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.
442442

443443
```ts no-transpile
444444
const action = createAction(type)
@@ -447,7 +447,7 @@ context.addCase(action, reducer)
447447

448448
#### `addMatcher`
449449

450-
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.
451451

452452
```ts no-transpile
453453
const matcher = isAnyOf(action, action2)
@@ -510,7 +510,7 @@ The type parameters for `SliceReducerCreators` are:
510510

511511
- `State` - The state type used by the slice.
512512
- `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.
514514

515515
The `ReducerCreatorEntry<Create, Exposes>` utility has two type parameters:
516516

@@ -900,7 +900,7 @@ toastSlice.caseReducers.showToast.hidden({}, showToast.hidden('id'))
900900

901901
#### Multiple definitions
902902

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/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.
904904

905905
One example could be returning some pagination related reducers.
906906

0 commit comments

Comments
 (0)