FieldOf

The props every widget takes, and how a widget states the value type it serves.

The props every widget takes: the field it renders, as a prop.

A widget states the value type it serves through FieldOf, and formdef reads it back to check that a field entry only names widgets that fit the field's value. Every other prop of the widget is its own and is passed through the entry's props.

Type parameters

NameDescription
TValueThe type of the value the widget renders and edits.

Example

const TextField = ({ field, label }: FieldOf<string> & { label?: string }) => (
  <label>
    {label}
    <input
      value={field.state.value}
      onChange={(event) => field.handleChange(event.target.value)}
      onBlur={field.handleBlur}
    />
  </label>
)

Members

Prop

Type

See also