question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass field as prop to FieldArray

See original GitHub issue

Bug, Feature, or Question?

Question / Feature

Current Behavior

Currently the <FieldArray /> gets only the arrayHelpers and form passed in as prop. Is there any reason it does not get the field property passed in? Now I have to get the values ‘manually’ from the form prop.

Desired Behavior

It would be nice to get at least the value from the field (based on the field name).

Suggested Solutions

Passing a similar field prop as the <Field /> component receives, except for the onChange and onBlur.

  • Formik Version: 0.11.0-beta.1
  • OS: Mac OS High Sierra
  • Node Version: 9.3.0
  • Package Manager and version: 1.3.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
charlaxcommented, Aug 6, 2018

+1

It would be nice also for extra props to be passed down the component:

See https://codesandbox.io/s/6y8q0ql34z

<FieldArray
            name="categoryIds"
            shouldBePassed="hello"
            component={props => {
              console.log(props)
              return null
    }
/>

In the current state, shouldBePassed will not be passed down to the rendered component.

3reactions
dmlukichevcommented, Sep 30, 2018

Also got confused by the fact that rest props are not passed to <FieldArray/> component. It would be nice to allow it.

At the same time workaround will look like this:

<FieldArray
    name="categoryIds"
    render={props => (
        <Component 
            {...props} 
            shouldBePassed="hello"
        />
    )
/>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing extra props to component wrapped in FieldArray ...
What I would like to be able to do is to pass a dictionary to 'emails' in order to populate the 'content' field...
Read more >
FieldArray - Redux Form
The FieldArray component is how you render an array of fields. ... Object with custom props to pass through the FieldArray component into...
Read more >
<FieldArray /> | Formik
<FieldArray /> is a component that helps with common array/list manipulations. You pass it a name property with the path to the key...
Read more >
useFieldArray - Simple React forms validation
Whether Field Array will be unregistered after unmount. keyName, string = id. Name of the attribute with autogenerated identifier to use as the...
Read more >
FieldArray | Vue Advanced Forms - GitHub Pages
A field's array name the internal form state. # component. A field wrapper component. Default span . # validation. The prop to pass...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found