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
Add prepare callback usage to createSlice.md (#231)
* Add prepare callback usage to createSlice.md
Added a description of the usage of a prepare callback to the createSlice API reference page. Also adapted the multiply case reducer in the example to demonstrate the usage.
* Reformatted changes in example
* Replace absolute link with a relative one
Co-Authored-By: Mark Erikson <mark@isquaredsoftware.com>
Copy file name to clipboardExpand all lines: docs/api/createSlice.md
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -82,6 +82,8 @@ to force the TS compiler to accept the computed property.)
82
82
Eachfunction defined in the `reducers` argument will have a corresponding action creator generated using [`createAction`](./createAction.md)
83
83
and included in the result's `actions` field using the same function name.
84
84
85
+
Ifyouneedtocustomizethecreationofthepayloadvalueofanactioncreatorbymeansofa [`prepare callback`](./createAction.md#using-prepare-callbacks-to-customize-action-contents), thevalueoftheappropriatefieldofthe`reducers`argumentobjectshouldbeanobjectinsteadofafunction. This object must contain two properties: reducer and prepare. The value of the reducer field should be the case reducer function while the value of the prepare field should be the prepare callback function.
86
+
85
87
Thegenerated`reducer`function is suitable for passing to the Redux `combineReducers` function as a "slice reducer".
0 commit comments