createAction Function
Deprecated in 4.15.0. Use your state management types instead, i.e. createAction from @reduxjs/toolkit
instead.
Creates a basic Redux Redux Action without a payload. This is meant to be used as a shortcut for defining Action Creators.
For example,
defines an action creator of type:
Note that the generic type parameters can always be omitted - TypeScript will be able to infer them.
createAction<T extends string>(type: T): Action<T>
Parameter | Type | Description |
---|---|---|
type | T | The string to use as the action's type property. Should have a string literal type. |
Returns - Action<T>
Creates a basic Redux Redux Action with a payload value. This is meant to be used as a shortcut for defining Action Creators.
For example,
defines an action creator of type:
Note that the generic type parameters can always be omitted - TypeScript will be able to infer them.
createAction<T extends string, P>(type: T, payload: P): ActionWithPayload<T, DeepReadonly<P>>
Parameter | Type | Description |
---|---|---|
type | T | The string to use as the action's type property. Should have a string literal type. |
payload | P | The value to use as the action's payload property. May be of any type. |
Returns - ActionWithPayload<T, DeepReadonly<P>>
Defined in
Last Updated: 29 April, 2025