reactjstypescriptreact-final-form

How can I write an adapter for my React Final Form component with Typescript?


I need to write an adapter for a component, to which I need to pass certain props. For example, I have a component which can receive certain props as "disabled", but I cannot indicate it in the tag of react form. I need to do this using typescript

In React final Form :

<Field name="email" component={mycomponent}>
</Field>

"mycomponent" is the one I need to be able to pass a prop, for example "disabled"


Solution

  • All props other than FieldProps are passed down to the component. So you could write:

    <Field name="email" component={MyComponent} disabled={true}>
    </Field>
    

    than MyComponent would receive disabled prop.