Skip to content

API reference > @kontsedal/olas-react > useFieldInput

useFieldInput() function ​

JSX-ready spread for a Field<T> whose value is not a string. transform converts between the field's value and the input's string: format forvalue, parse for each change.

tsx
<input type="number" {...useFieldInput(age, { transform: { parse: Number, format: String } })} />

Signature:

typescript
export declare function useFieldInput<T>(field: Field<T>, options: UseFieldInputOptions<T> & {
  transform: FieldTransform<T>;
}): UseFieldInputResult;

Parameters ​

Parameter

Type

Description

field

Field<T>

options

UseFieldInputOptions<T> & { transform: FieldTransform<T>; }

Returns:

UseFieldInputResult

Released under the MIT License.