Formik: Pass field as prop to FieldArray

Created on 14 Jan 2018  路  5Comments  路  Source: formium/formik

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
Enhancement stale

Most helpful comment

+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.

All 5 comments

+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.

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"
        />
    )
/>

Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.

Update: plan is to likely deprecated FieldArray and move these manipulations into core

Closing as stale

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaredpalmer picture jaredpalmer  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments

najisawas picture najisawas  路  3Comments

jeffbski picture jeffbski  路  3Comments

emartini picture emartini  路  3Comments