Usage
A field component that accepts UseFieldReturnType can be used in any form.
Pass it form.getField('path') from use-form or the return value of useField:
Field object
form.getField('path') returns the same object as use-field.
Its methods read and change the field without knowing which form renders it:
Type checking
The path passed to form.getField must exist in form values, and its value type must match
the type of the field component:
Validation
Validation rules are defined on useForm or useField, the field component only renders the input.
Export the rule next to the component to reuse it:
Checkbox fields
For checkbox fields, type the component with UseFieldReturnType<boolean, 'checkbox'> and
pass { type: 'checkbox' } to form.getField or useField:
Groups of fields
A component that renders several fields accepts the form object.
UseFormReturnType<{ email: string }> accepts any form with a top-level email string.
To render fields under a path that differs between forms, type the path with FormPath: