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
foractionProps
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
submitTrixtaActionResponseparameters
autoSubmit: boolean
Optional
Defaults to false.
If set to
true
, hook will submitactionParameters
toactionName
when the component mounts.
Returns
hasRoleAccess : boolean
Will be
true
if theroleName
has access for this user.
isInProgress : boolean
value is based on useTrixtaAction or useTrixtaReaction
hasActionResponse : boolean
value is based on
hasResponse
from useTrixtaAction
hasReactionResponse : boolean
value is based on
hasResponse
from useTrixtaReaction
initialData : TInitialData on
TrixtaReactionInstance
Initial data returned from Trixta reaction instance
hasResponse : boolean
value is based on
hasReactionResponse
orhasActionResponse
.
loading : boolean
value is based on useTrixtaAction or useTrixtaReaction.
reactionResponse :
TrixtaInstanceResponse
value is based on
latestResponse
from useTrixtaReaction
actionResponse :
TrixtaInstance
value is based
response
from useTrixtaAction
submitTrixtaActionResponse : (parameters:
SubmitTrixtaFunctionParameters
) => void
function is based on
submitTrixtaAction
from useTrixtaAction
clearActionResponses : () => void
function is based on
clearActionResponses
from useTrixtaAction
clearReactionResponses : () => void
function is based on
clearReactionResponses
from useTrixtaReaction
submitTrixtaReactionResponse : (parameters:
SubmitTrixtaFunctionParameters
) => void
function is based on
submitTrixtaReaction
from useTrixtaReaction
Last updated
Was this helpful?