react-final-form-arrays icon indicating copy to clipboard operation
react-final-form-arrays copied to clipboard

Fields names getter

Open omerman opened this issue 4 years ago • 1 comments

Hey, say I have this code:

type FormValues =  {
  x: [{id: number, value: string}]
}
 const { fields } = useFieldArray(
    "x",
    {
      isEqual,
      // re-render uppon array values change
      subscription: { value: true },
    }
  );

Now sometimes I don't need to use fields.map, say I want to render the item in the 5th cell, assuming I know it exists..

How would I get the prefix name of the cell? surely I can write "x[5].value", but I wanted something like ${field.names[5]}.value also maybe instead of fields.map, make it fields.names.map

Great library, thank you for final-form & react-final-form & this plugin :), looking forward for your response

omerman avatar Jul 18 '20 18:07 omerman

Thought about it a bit more, maybe an api such as fields.get(5) that will return the string name prefix. since fields.names[index]/fields.names.map may break the current behavior.

omerman avatar Jul 18 '20 20:07 omerman