Skip to content

Commit

Permalink
Add otherProp to FieldRenderProps interface (#716)
Browse files Browse the repository at this point in the history
I believe that the FieldRenderProps interface is typed incorrectly, it should actually allow `[otherProp: string]: any;`. Trying to access props other than `input` or `meta` will currently result in a Typescript error.

As shown in the docs (here)[https://final-form.org/docs/react-final-form/types/FieldProps#children] arbitrary props assigned to the `Field` component are passed through to the renderProp.

```js
<Field name="myField" someArbitraryOtherProp={42}>
  {props => {
    console.log(props.someArbitraryOtherProp) // would print 42
    return <input {...props.input}/>
  }}
</Form>
```

We can see the passing of props in the `renderComponent` module here: https://github.com/final-form/react-final-form/blob/master/src/renderComponent.js#L25
  • Loading branch information
bhishp authored and erikras committed Jan 21, 2020
1 parent ce42986 commit 71ce8e2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions typescript/index.d.ts
Expand Up @@ -46,6 +46,7 @@ export interface FieldRenderProps<
> {
input: FieldInputProps<FieldValue, T>;
meta: FieldMetaState<FieldValue>;
[otherProp: string]: any;
}

export interface FormRenderProps<FormValues = AnyObject>
Expand Down

0 comments on commit 71ce8e2

Please sign in to comment.