This page provides detailed information about the parameters, return values, and types for the useAction
hook.
Property | Type | Description |
---|
action | GeneratedActionHandler | An action created using the createAction function from @vergestack/api . |
options | UseActionOptions<OutputType> | Optional configuration options for the useAction hook. |
The useAction
hook returns an object with the following properties:
Property | Description |
---|
isPending | A boolean indicating whether the asynchronous operation is in progress. |
isSuccess | A boolean indicating whether the operation completed successfully. |
isError | A boolean indicating whether the operation resulted in an error. |
errors | An array of ApiErrorWithMetadata objects if the asynchronous operation fails. |
data | The data returned by the asynchronous operation. |
status | The HTTP status code of the response. |
execute | A function to manually trigger the execution of the asynchronous operation. |
handlers | An object containing form action and onSubmit handlers for progressive enhancement. |
getFormError | A function to retrieve form-specific errors (useful for inline form errors). |
Prop | Type | Default |
---|
status
| ApiResponseSuccessCodes
| - |
data
| NonNullable<T>
| - |
errors
| never
| - |
Prop | Type | Default |
---|
status
| ApiResponseErrorCodes
| - |
data
| never
| - |
errors
| ApiError[]
| - |
Prop | Type | Default |
---|
message
| string
| - |
reason
| string
| - |
For more information on how to use these types and properties, refer to the Form Usage and Advanced Usage guides.