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
While typically [custom creators](/usage/custom-slice-creators) will be provided on a per-app basis (see [`buildCreateSlice`](#buildcreateslice)), this field allows for custom slice creators to be passed in per slice.
464
+
465
+
This is particularly useful when using a custom creator that is specific to a single slice.
466
+
467
+
An error will be thrown if there is a naming conflict between an app-wide custom creator and a slice-specific custom creator.
468
+
459
469
## Return Value
460
470
461
471
`createSlice` will return an object that looks like:
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).
50
50
51
+
:::note
52
+
53
+
Creators can also be [passed per slice](/api/createSlice#creators), but most creators will be useful in more than one slice - so it's recommended to pass them to `buildCreateSlice` instead.
@@ -166,7 +172,7 @@ The [creator definition](#creator-definitions) for `create.preparedReducer` is e
166
172
167
173
These creators are not included in the default `create` object, but can be added by passing them to [`buildCreateSlice`](../api/createSlice#buildcreateslice).
168
174
169
-
The name the creator is available under is based on the key used when calling `buildCreateSlice`. For example, to use `create.asyncThunk`:
175
+
The name the creator is available under is based on the key used when calling `buildCreateSlice` (or [`createSlice`](/api/createSlice#creators)). For example, to use `create.asyncThunk`:
@@ -464,7 +470,7 @@ Typically a creator will return a [single reducer definition](#single-definition
464
470
465
471
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.
466
472
467
-
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.
473
+
It's passed to [`buildCreateSlice`](../api/createSlice#buildcreateslice)(or [`createSlice`](/api/createSlice#creators)) 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.
0 commit comments