useField()function

useField(name: string, form?: FormStore<{ [name: string]: T }>): SchemaInputProps<Schema<T>, I>
ParamType
namestring
Name of the field to read props for. required
formFormStore<{ [name: string]: T }>
Form store to read from, defaulting to the current form context.
Return
SchemaInputProps<Schema<T>, I>
Props (name, schema, value, onValue, message, required) ready to spread onto an input.

Hook that returns the input props for a single named field of a form.

  • Subscribes to the form store so the field re-renders when its value or message changes.

Examples

const field = useField("email");