Skip to content

useFieldErrors

useFieldErrors subscribes to the validation errors for a field. It will only trigger a rerender when the errors change.

const form = useForm({
initialValues: { username: "" }
});
const errors = useFieldErrors(form("username"));
//^? ReadonlyArray<string>
if (errors.length) {
return (
<div>
Issues: { errors.join(", ") }
</div>
)
}
function useFieldErrors(field: FormField<any>): ReadonlyArray<string>