Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IUseField<T, R>

Resulting object upon initializing useField.

Type parameters

Hierarchy

  • IUseField

Index

Properties

data

data: any

The current form's data model value. NOTE: Does NOT perform render. see .render();

Readonly default

default: string

Gets default value by path.

Readonly dirty

dirty: boolean

Indicates if the field/element is dirty.

Readonly element

element: IRegisteredElement<T>

Exposes access to the hook's bound element in your form. This allows you to get/set properties directly on your element.

Readonly errors

Returns the current errors for a field/element.

Readonly invalid

invalid: boolean

Returns true when the field/element has errors and is invalid.

Readonly message

message: string

Returns the current top error for a field/element.

Readonly messages

messages: string[]

Returns current error messages for a field/element.

Readonly name

name: string

The element name, name of hook.

Readonly path

path: string

The data path in your model which this field/element gets/sets data from.

register

register: R

Registers the element.

Readonly touched

touched: boolean

Indicates if the field/element is touched.

unregister

unregister: () => void

Unregisters the ref/field from Komo.

Type declaration

    • (): void
    • Returns void

Readonly valid

valid: boolean

Returns true if the field/element is valid or without errors.

value

value: string

Gets the element's current value. NOTE: Does not perform render. see .render();

Methods

blur

  • blur(event?: BaseSyntheticEvent): void
  • Causes the element to blur.

    Parameters

    • Optional event: BaseSyntheticEvent

      the react synthetice event.

    Returns void

focus

  • focus(event?: BaseSyntheticEvent): void
  • Sets focus for element.

    Parameters

    • Optional event: BaseSyntheticEvent

      the react synthetice event.

    Returns void

render

  • render(): void
  • Triggers a form render, useful when manually updating, valdiating elements. You should not use this method unless you're sure you need to. It will be obvious.

    Returns void

reset

  • reset(): void
  • Resets the field removing touched, dirty and errors, sets back to default value.

    Returns void

update

  • update(value: any, modelValue?: any, validate?: boolean): void
  • Updates the value and model value for an element and performs render. When no modelValue is provided the value is used. Set validate to false if you wish to validate manually.

    Parameters

    • value: any

      the value to update to.

    • Optional modelValue: any

      optional model value.

    • Optional validate: boolean

      when NOT false validate the element.

    Returns void

validate

validateAt

Generated using TypeDoc