Skip to content

useSubmissionError

useSubmissionError accepts a form and returns the Error that was thrown when the form was last submitted, or undefined.

If a non-Error was thrown, then the value which was thrown will be wrapped in an Error and Error#cause will be set.

const form = useForm({
initialValues: { username: "" }
});
const submissionError = useSubmissionError(form);
//^? Error | undefined
if (submissionError) {
return <div>There was an error</div>
}
function useSubmissionError(form: Form<any>): Error | undefined