Skip to content

Commit c8af945

Browse files
committed
add notes about type parameters
1 parent 8af2b00 commit c8af945

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

docs/api/createSlice.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,12 +1126,24 @@ declare module '@reduxjs/toolkit' {
11261126
}
11271127
```
11281128
1129+
The type parameters for `SliceReducerCreators` are:
1130+
1131+
- `State` - The state type used by the slice.
1132+
- `CaseReducers` - The case reducer definitions returned by the creator callback.
1133+
- `Name` - The [`name`](#name) used by the slice.
1134+
11291135
The `ReducerCreatorEntry<Create, Exposes>` utility has two type parameters:
11301136
11311137
##### `Create`
11321138
11331139
The signature of the `create` method of the creator definition.
11341140
1141+
:::caution `CaseReducers` and `Name`
1142+
1143+
Your `Create` type should not depend on the `CaseReducers` and `Name` type parameters, as these will not yet exist when the creator is being called.
1144+
1145+
:::
1146+
11351147
:::tip Using `this` to access other creators
11361148
11371149
Assuming the creator is called as `create.yourCreator()`, the `this` value for the function is the `create` object - meaning you can call other creators on the same object.
@@ -1223,7 +1235,7 @@ declare module '@reduxjs/toolkit' {
12231235
12241236
:::
12251237
1226-
##### `Exposes`
1238+
##### `Exposes` (optional)
12271239
12281240
The second type parameter for `ReducerCreatorEntry` is optional, but should be used if the creator will handle some reducer definitions itself. It indicates what actions and case reducers will be attached to the slice, and is used to determine the final types of `slice.actions` and `slice.caseReducers`.
12291241

0 commit comments

Comments
 (0)