Field
Type Alias
An object that represents a single field in a form. This includes both primitive value fields
(e.g. fields that contain a string
or number
), as well as "grouping fields" that contain
sub-fields. Field
objects are arranged in a tree whose structure mimics the structure of the
underlying data. For example a Field<{x: number}>
has a property x
which contains a
Field<number>
. To access the state associated with a field, call it as a function.
API
type Field<TValue, TKey extends string | number = string | number> = (() => FieldState< TValue, TKey>) & (TValue extends Array<infer U> ? ReadonlyArrayLike<MaybeField<U, number>> : TValue extends Record<string, any> ? Subfields<TValue> : unknown)
Jump to details