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 name to ArrayField #403

Merged
merged 1 commit into from
Feb 5, 2018
Merged

Add name to ArrayField #403

merged 1 commit into from
Feb 5, 2018

Conversation

a-tarasyuk
Copy link
Contributor

@a-tarasyuk a-tarasyuk commented Feb 5, 2018

ArrayField component/render/children does not have access to name property from parent

form.ts

<ArrayField name={'roles'} component={ Roles } />

roles.ts

const Roles = ({ name, form  }) => {
   const { values, setFieldValue } = form; 
   
   return (
      <>
         { values[name].map(role => <input .... onChange={ (e) => setFieldValue(name, e.target.value) } />}
      </>
    )
}

Would be useful to have access to the property name from ArrayField name={'roles'} in order to avoid code duplication and avoid mistakes with names. @jaredpalmer could you review?

@jaredpalmer
Copy link
Owner

Sure.

@jaredpalmer jaredpalmer merged commit ed3aa53 into jaredpalmer:master Feb 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants