Aborting navigations
Aborting navigations can be done with the useAbort hook.
function Route() {
let abort = useAbort();
let [Form, busy, loading, navigations] = useForm();
function handleAbortButtonClick() {
abort(navigations); // aborts all navigations from the Form
}
return (
<>
<Form method="post">...</Form>
<button onClick={handleAbortButtonClick}>Abort</button>
</>
);
}
Be aware that the navigations array from the useLink
, useForm
, and useNavigate
hooks are only those
navigations that were initiated from the Link, Form, or navigate function from the hook itself.
If you need to abort all navigations globally, call abort without navigations.
function Route() {
let abort = useAbort()
function handleAbortButtonClick() {
abort() // aborts all navigations globally
}
...
}