Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

useField.md

51 lines1.1 KB

UseField<TParentData>

A type representing a hook for using a field in a form with the given form data type.

export type UseField = <TField extends DeepKeys<TParentData>>(
  opts?: { name: TField } & FieldOptions<
    DeepValue<TParentData, TField>,
    TParentData
  >,
) => FieldApi<DeepValue<TParentData, TField>, TParentData>
  • A function that takes an optional object with a name property and field options, and returns a FieldApi instance for the specified field.

useField

export function useField<TData, TParentData>(
  opts: FieldOptions<TData, TParentData>,
): FieldApi<TData, TParentData>

A hook for managing a field in a form.

  • opts: FieldOptions<TData, TParentData>
    • An object with field options.

Returns

  • FieldApi<TData, TParentData>
    • The FieldApi instance for the specified field.

createUseField

export function createUseField<TParentData>(
  formApi: FormApi<TParentData>,
): UseField<TParentData>

A function that creates a UseField hook bound to the given formApi.