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

451 Views Asked by At

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"

1

There are 1 best solutions below

0
On BEST ANSWER

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.