React Flexible FormDocsExamplesGitHub
DocumentationOverviewGetting StartedTypeScriptAPIuseFormFielduseSubformuseFieldArrayuseConvertutilsExamplesSimple FormChakra UI FormForm with ArraySubformCustom useConvertForm State in ReduxForm with LoaderForm based on Material UIThrottled error validation

Field

Field is a wrapper for frorm field controls. It gets value, error, touched and dirty props from formControl and renders component that is passes in rffComponent prop.

<Field
  rffFormControl={formControl}
  rffName="firstName"
  rffComponent={Input}
/>

Different components need different props. For example html <input /> has onChange: (event: ChangeEvent) => void and input value will be at event.target.value. But ReactSelect has such onChange: (value: SignleValue<T>), and value is the selected object. Same will apply how errors should be displayed and so on.


To be able to use Field with any compnent, optional prop useConvert can be used. It will accept rffFormControl and rffName as arguments and should provide momoized onChange, onBlur, value and error props. Names of them can be different. Then Field can wrap any component.


See example with custom useConvert.

Props

All props of the <Field /> start with rff prefix (stands for React Flexible Form). This is to avoid name conflicts with rffComponent own props that if passed to <Field /> and will be passed to rffComponent when rendering.


Field will also accept all props of the rffComponent and will pass the thru.