useTrixtaAction
React hook used to interact with a Trixta action for a given roleName.
Options
roleName : string
Required
Trixta role name
actionName : string
Required
Trixta action name
actionParameters: see related
submitTrixtaActionResponseparameters
loadingStatusRef: string
Optional
Optional value to change the default isInProgress behaviour for when submitting actions. If you plan to use the same action name for the same role, on the same screen, this is when you would make use of this * property
options: { debugMode, autoSubmit, setTimeoutEventAsErrorEvent, clearResponsesOnCallback }
debugMode: boolean
Optional
Defaults to false.
If set to
true
, enables Trixta console debugging
autoSubmit: boolean
Optional
Defaults to false.
If set to
true
, hook will submitactionParameters
toactionName
when the component mounts.
setTimeoutEventAsErrorEvent: boolean
Optional
Defaults to false.
If set to
true
, will set theactionParameters
timeoutEvent
to be the same as theerrorEvent
clearResponsesOnCallback: boolean
Optional
Defaults to false.
If set to
true
, will clear all responses whenonSuccess
oronError
callbacks are called returning a value true.
onSuccess : (success: TSuccessType) => void|boolean
Optional
This function will fire any time a successful response is received from Trixta.
If you return
true
and clearResponsesOnCallback istrue
, all responses will be cleared.
onError : (error: TErrorType) => void|boolean
Optional
This function will fire any time an error response is received from Trixta.
If you return
true
and clearResponsesOnCallback istrue
, all responses will be cleared.
Returns
hasRoleAccess : boolean
Will be
true
if theroleName
has access for this user.
isInProgress : boolean
Will be
true
if there is no response yet after callingsubmitTrixtaActionResponse
orsubmitTrixtaAction
.Will be
false
if there is a response after callingsubmitTrixtaActionResponse
orsubmitTrixtaAction
hasResponse : boolean
Will be
true
if there is at least one Trixta Instance response.
loading : boolean
Will be
true
if the action is waiting to be loaded.
response :
TrixtaInstanceResponse
First or most recent Trixta instance response
latestInstance : TrixtaInstance
First or most recent Trixta instance
submitTrixtaAction : (parameters:
SubmitTrixtaFunctionParameters
) => void
This function will submit a request for the given
roleName
andactionName
clearActionResponses : () => void
This function will clear and reset responses for the given
roleName
andactionName
.
Last updated