Capítulo 15 de 29
Listeners (onChange/onBlur/onMount/onSubmit/onUnmount) run side effects in response to form/field events — deliberately separate from validators, so "reset a dependent field when this one changes" doesn't have to be smuggled into a validator function.
useForm's listeners) fire on every relevant event across the whole form.onChangeDebounceMs/onBlurDebounceMs apply the same debounce mechanism validators get, without needing a validator.const form = useForm({
listeners: {
onChange: ({ formApi }) => {
if (formApi.state.isValid) formApi.handleSubmit() // auto-save
},
onChangeDebounceMs: 500,
},
})
<form.Field
name="country"
listeners={{ onChange: () => form.setFieldValue('province', '') }}
>
{(field) => <input value={field.state.value} />}
</form.Field>
undefined.onChangeDebounceMs/onBlurDebounceMs mirror validators' async debounce options but apply to listeners specifically — set them independently if a listener needs different timing than the field's validators.formApi.handleSubmit(), used here for auto-save.