Hook callbacks
onExecute
: called whenstatus
is"executing"
.onSuccess
: called whenstatus
is"hasSucceeded"
.onError
: called whenstatus
is"hasErrored"
.onSettled
: called whenstatus
is either"hasSucceeded"
or"hasErrored"
.
Hook callbacks are a way to perform custom logic based on the current action execution status. You can pass them to the three hooks in the utils
object, which is the second argument. All of them are optional and don't return anything, they can also be async or not:
const action = useAction(testAction, {
onExecute: ({ input }) => {},
onSuccess: ({ data, input }) => {},
onError: ({ error, input }) => {},
onSettled: ({ result, input }) => {},
});