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 : stringRequired
Trixta role name
actionName : stringRequired
Trixta action name
reactionProps: { roleName, reactionName, requestForEffect }roleName : string?Optional
Trixta role name
If the
roleNameforactionPropsis the same, this can be excluded
reactionName : stringRequired
Trixta reaction name
requestForEffect: booleanOptional
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 relatedsubmitTrixtaActionResponseparametersautoSubmit: booleanOptional
Defaults to false.
If set to
true, hook will submitactionParameterstoactionNamewhen the component mounts.
Returns
hasRoleAccess : booleanWill be
trueif theroleNamehas access for this user.
isInProgress : booleanvalue is based on useTrixtaAction or useTrixtaReaction
hasActionResponse : booleanvalue is based on
hasResponsefrom useTrixtaAction
hasReactionResponse : booleanvalue is based on
hasResponsefrom useTrixtaReaction
initialData : TInitialData onTrixtaReactionInstanceInitial data returned from Trixta reaction instance
hasResponse : booleanvalue is based on
hasReactionResponseorhasActionResponse.
loading : booleanvalue is based on useTrixtaAction or useTrixtaReaction.
reactionResponse :TrixtaInstanceResponsevalue is based on
latestResponsefrom useTrixtaReaction
actionResponse :TrixtaInstancevalue is based
responsefrom useTrixtaAction
submitTrixtaActionResponse : (parameters:SubmitTrixtaFunctionParameters) => voidfunction is based on
submitTrixtaActionfrom useTrixtaAction
clearActionResponses : () => voidfunction is based on
clearActionResponsesfrom useTrixtaAction
clearReactionResponses : () => voidfunction is based on
clearReactionResponsesfrom useTrixtaReaction
submitTrixtaReactionResponse : (parameters:SubmitTrixtaFunctionParameters) => voidfunction is based on
submitTrixtaReactionfrom useTrixtaReaction
Last updated
Was this helpful?