Function useField

  • Hook used to gain access to field-specific state and methods Causes the component to subscribe to all changes of the field's state.

    Type Parameters

    • T

    • Err

    Parameters

    • fieldDescriptor: GenericFieldDescriptor<T, Err>

      pointer to a field containing type information and more. Obtained from FormSchema.

    • Optional controller: FormController

      obtained by using useFormController hook, used to connect to form state. Injected automatically via React Context when used inside FormProvider component.

    Returns FieldHandle<T, Err>

    FormHandle object used to interact with the field

    Example

    const Schema = new FormSchemaBuilder()...;

    const MyForm: React.FC = () => {
    const controller = useFormController({ Schema })
    const username = useField(Schema.username, controller)

    ...
    }

Generated using TypeDoc