Subcribers

The library offers you the possibility to watch one, multiple or all values of a form. You can watch values on change or on blur.

Example

In this example, we are watching values of a simple form with the two hooks provider for this: useOnChangeValues and useOnBlurValues. The watch is scoped on field name. A render will only be done when the value is updated

Global watching

You can also watch all values of a form by using the following code

const form = useFormContext<FormValues>();
const values = useOnBlurValues(form, undefined);

// Or

const form = useFormContext<FormValues>();
const values = useOnChangeValues(form, undefined);
WARNING

Global watching is, by definition, not scoped to some field, so the hook will re-render every time a value in the form is updated. This can cause performance issues in a large form.