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
Copy file name to clipboardExpand all lines: docs/usage/custom-slice-creators.mdx
+18-2Lines changed: 18 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -429,10 +429,12 @@ A creator only needs a `handle` callback if it expects to be called with reducer
429
429
430
430
It receives three arguments: details about the reducer, the definition, and a `context` object with methods to modify the slice.
431
431
432
-
The reducer details object has two properties:
432
+
The reducer details object has the following properties:
433
433
434
+
-`sliceName` - the name of the slice the reducer is being added to (e.g. `entities/todos`)
435
+
-`reducerPath` - the `reducerPath` passed to `createSlice` (e.g. `todos`) (defaults to `sliceName` if not provided)
434
436
-`reducerName` - the key the reducer definition was under (e.g. `addTodo`)
435
-
-`type` - the automatically generated type string for the reducer (e.g. `todos/addTodo`)
437
+
-`type` - the automatically generated type string for the reducer (e.g. `entities/todos/addTodo`)
436
438
437
439
The context object includes:
438
440
@@ -484,6 +486,19 @@ context
484
486
.exposeCaseReducer(resetReducer)
485
487
```
486
488
489
+
#### `selectSlice`
490
+
491
+
Tries to select the slice's state from the root state, using the original `reducerPath` option passed when calling `createSlice` (which defaults to the `name` option). Throws an error if it can't find the slice.
The Typescript system for custom slice creators uses a "creator registry" system similar to the module system for [RTK Query](/rtk-query/usage/customizing-create-api#creating-your-own-module).
@@ -512,6 +527,7 @@ The type parameters for `SliceReducerCreators` are:
512
527
-`State` - The state type used by the slice.
513
528
-`CaseReducers` - The case reducer definitions returned by the creator callback.
514
529
-`Name` - The [`name`](../api/createSlice#name) used by the slice.
530
+
-`ReducerPath` - The [`reducerPath`](../api/createSlice#reducerpath) used by the slice.
515
531
516
532
The `ReducerCreatorEntry<Create, Exposes>` utility has two type parameters:
0 commit comments