Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add otherProp to FieldRenderProps interface #716

Merged
merged 1 commit into from
Jan 21, 2020

Conversation

bhishp
Copy link
Contributor

@bhishp bhishp commented Jan 13, 2020

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 arbitrary props assigned to the Field component are passed through to the renderProp.

<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

Related issue

Seems an issue is already raised regarding this:

#398

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
@codecov
Copy link

codecov bot commented Jan 13, 2020

Codecov Report

Merging #716 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #716   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          17     17           
  Lines         251    251           
  Branches       58     58           
=====================================
  Hits          251    251

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3237bc8...54b9081. Read the comment docs.

@erikras erikras merged commit 71ce8e2 into final-form:master Jan 21, 2020
@erikras
Copy link
Member

erikras commented Jan 22, 2020

Published in v6.3.4.

@lock
Copy link

lock bot commented Feb 21, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 21, 2020
@bhishp bhishp deleted the patch-1 branch February 23, 2020 20:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants