Skip to content

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

Closed
@GavinThompson

Description

@GavinThompson

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?

Activity

erikras

erikras commented on Jan 4, 2018

@erikras
Member

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

GavinThompson commented on Jan 4, 2018

@GavinThompson
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

shrynx commented on Jan 24, 2018

@shrynx

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

davidroeca

davidroeca commented on Feb 7, 2019

@davidroeca

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

erikras commented on Aug 15, 2019

@erikras
Member

Published fix in v3.1.1.

locked as resolved and limited conversation to collaborators on May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @GavinThompson@erikras@shrynx@davidroeca

      Issue actions

        FieldArray gives my rendered component a prop called `value`, is this a public API? · Issue #13 · final-form/react-final-form-arrays