File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,27 @@ expect(increment(error)).to.deep.equal({
4747});
4848```
4949
50+ ` createAction ` also returns its ` type ` when used as type in ` handleAction ` or ` handleActions ` .
51+
52+ Example:
53+
54+ ``` js
55+ const increment = createAction (' INCREMENT' );
56+
57+ // As parameter in handleAction:
58+ handleAction (increment, {
59+ next (state , action ) {... }
60+ throw (state, action) {... }
61+ });
62+
63+ // As object key in handleActions:
64+ const reducer = handleActions ({
65+ [increment]: (state , action ) => ({
66+ counter: state .counter + action .payload
67+ })
68+ }, { counter: 0 });
69+ ```
70+
5071** NOTE:** The more correct name for this function is probably ` createActionCreator() ` , but that seems a bit redundant.
5172
5273Use the identity form to create one-off actions:
You can’t perform that action at this time.
0 commit comments