> For the complete documentation index, see [llms.txt](https://trixtateam.gitbook.io/trixta-js-core/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trixtateam.gitbook.io/trixta-js-core/reference/hooks/usetrixtaactionreaction.md).

# useTrixtaActionReaction

{% code overflow="wrap" %}

```tsx
import { useTrixtaActionReaction } from '@trixtateam/trixta-js-core';
const { 
hasRoleAccess,
initialData,
isInProgress,
hasResponse,
hasActionResponse,
hasReactionResponse,
loading,
actionResponse,
reactionResponse,
submitTrixtaActionResponse,
submitTrixtaReactionResponse,
clearActionResponses,
clearReactionResponses,
} = useTrixtaActionReaction<TInitialData,
TActionResponseType,
TActionErrorType,
TReactionResponseType,
TReactionErrorType
>({ 
  actionProps:{
    roleName:"",
    actionName:"",
  },
  reactionProps:{
    roleName:"",
    reactionName:"",
  },
  autoSubmit:false,
  actionParameters:{
    data:{},
    extraData:{},
    timeout:1500,
    timeoutEvent:"",
    loadingStatusRef:"",
    requestEvent:"",
    responseEvent:"",
    errorEvent:""
  }
   });
```

{% endcode %}

### Options

* `actionProps: { roleName, actionName }`
  * `roleName : string`
    * **Required**
    * Trixta role name
  * `actionName : string`
    * **Required**
    * Trixta action name

* `reactionProps: { roleName, reactionName, requestForEffect }`
  * `roleName : string?`
    * Optional
    * Trixta role name
    * If the `roleName` for `actionProps`   is the same, this can be excluded
  * `reactionName : string`
    * **Required**
    * Trixta reaction name
  * `requestForEffect: boolean`

    * Optional
    * Defaults to false.
    * If set to `true`, this Trixta reaction is not waiting for a response and the only expect to use the initialData

* `actionParameters: see related` [submitTrixtaActionResponse](/trixta-js-core/reference/methods/actions/submittrixtaactionresponse.md) `parameters`

* `autoSubmit: boolean`
  * Optional
  * Defaults to false.
  * If set to `true`, hook will submit `actionParameters` to `actionName` when the component mounts.

### Returns

* `hasRoleAccess : boolean`

  * Will be `true` if the `roleName` has access for this user.

* `isInProgress : boolean`

  * value is based on [useTrixtaAction](/trixta-js-core/reference/hooks/actions/usetrixtaaction.md) or [useTrixtaReaction](/trixta-js-core/reference/hooks/reactions/usetrixtareaction.md)

* `hasActionResponse : boolean`

  * value is based on `hasResponse` from [useTrixtaAction](/trixta-js-core/reference/hooks/actions/usetrixtaaction.md)

* `hasReactionResponse : boolean`

  * value is based on `hasResponse` from [useTrixtaReaction](/trixta-js-core/reference/hooks/reactions/usetrixtareaction.md)

* `initialData : TInitialData on` [`TrixtaReactionInstance`](/trixta-js-core/reference/types/reaction-related-types.md)

  * Initial data returned from Trixta reaction instance

* `hasResponse : boolean`

  * value is based on `hasReactionResponse` or `hasActionResponse` .

* `loading : boolean`

  * value is based on [useTrixtaAction](/trixta-js-core/reference/hooks/actions/usetrixtaaction.md) or [useTrixtaReaction](/trixta-js-core/reference/hooks/reactions/usetrixtareaction.md).

* `reactionResponse :` [`TrixtaInstanceResponse`](/trixta-js-core/reference/types/action-related-types.md)

  * value is based on `latestResponse` from [useTrixtaReaction](/trixta-js-core/reference/hooks/reactions/usetrixtareaction.md)

* `actionResponse :` [`TrixtaInstance`](/trixta-js-core/reference/types/action-related-types.md)

  * value is based `response` from [useTrixtaAction](/trixta-js-core/reference/hooks/actions/usetrixtaaction.md)

* `submitTrixtaActionResponse : (parameters:` [`SubmitTrixtaFunctionParameters`](/trixta-js-core/reference/methods/actions/submittrixtaactionresponse.md)`) => void`

  * function is based on `submitTrixtaAction` from [useTrixtaAction](/trixta-js-core/reference/hooks/actions/usetrixtaaction.md)&#x20;

  &#x20;

* `clearActionResponses : () => void`

  * function is based on `clearActionResponses` from [useTrixtaAction](/trixta-js-core/reference/hooks/actions/usetrixtaaction.md)&#x20;

* `clearReactionResponses : () => void`

  * function is based on `clearReactionResponses` from [useTrixtaReaction](/trixta-js-core/reference/hooks/reactions/usetrixtareaction.md)

* `submitTrixtaReactionResponse : (parameters:` [`SubmitTrixtaFunctionParameters`](/trixta-js-core/reference/methods/reactions/submittrixtareactionresponse.md)`) => void`

  * function is based on `submitTrixtaReaction` from [useTrixtaReaction](/trixta-js-core/reference/hooks/reactions/usetrixtareaction.md)

  &#x20;
