Skip to content

FieldArray gives my rendered component a prop called value, is this a public API? #13

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

Closed
GavinThompson opened this issue Jan 4, 2018 · 5 comments · Fixed by #96
Closed

Comments

@GavinThompson
Copy link

Are you submitting a bug report or a feature request?

Bug report, maybe? Docs?

What is the current behavior?

The component I pass to <FieldArray> in the component prop receives a prop called value. Is this a public/stable API?

I don't see this in FieldArrayRenderProps, either in the docs or the flow types.

What is the expected behavior?

Sandbox Link

Here's the FieldArray example, adapted to show I can read from the value prop.

https://codesandbox.io/s/n1nn8rpjwl

What's your environment?

Same as the example codesandbox.

Other information

Ultimately what I'm looking for is a way to read from the FieldArray programmatically/imperatively.

In redux-form I could use .get() and/or .getAll(), but this isn't available in react-final-form.

Any guidance?

@erikras
Copy link
Member

erikras commented Jan 4, 2018

Wow. Brilliant observation! I totally overlooked that.

Let me think about it, but without thinking too much about it, I'm leaning towards the redux-form API...

@GavinThompson
Copy link
Author

Excellent, thanks for the quick response! Will hold off on any more changes on our end and circle back in the near future. Thanks again! 😄

@shrynx
Copy link

shrynx commented Jan 24, 2018

@erikras It seems this been removed from the latest version, any plans for alternate api ?

@davidroeca
Copy link

It would be really nice to have the get functionality. As a work-around, I had success with the Field component; it works with both the entire FieldArray name as well as the field name from a call to fields.map():

<FieldArray name='myArray'>
  {({ fields }) => (
    <React.Fragment>
      {fields.map((name) => (
        <Field name={name} subscription={{value: true}}>
          {({ input: { value: field }}) => (
            <div>{JSON.stringify(field, null, 2)}</div>
          )}
        </Field>
      )}
      <Field name='myArray' subscription={{value: true}}>
        {({ input: { value: fieldValues }}) => (
          <div>{JSON.stringify(fieldValues, null, 2)}</div>
        )}
      </Field>
    </React.Fragment>
  )}
</FieldArray>

@erikras
Copy link
Member

erikras commented Aug 15, 2019

Published fix in v3.1.1.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2025
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 a pull request may close this issue.

4 participants