useTrixtaActionReaction

React hook used to interact with a Trixta action and reaction for a given roleName. This hook uses a combination of both the useTrixtaAction and useTrixtaReaction hooks.

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:""
  }
   });

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 parameters

  • autoSubmit: boolean

    • Optional

    • Defaults to false.

    • If set to true, hook will submit actionParameters to actionName when the component mounts.

Returns

Last updated