2

Im using final-form/react-final-form-arrays library is there a way to sort by most recent field appearing first. The FieldArray component has the fields prop which is array like but does not have a reverse function. So each time I add a new field e.g fields.push({newObject}) I want that rendered component to be at the top of the list. Anyone know how to make this work?

Sean
  • 43
  • 5

1 Answers1

2

Yes, there is a way to add values to the top instead of the bottom.

Simply replace

fields.push({});

with

fields.unshift({});

More details can also be found in the root readme: https://github.com/final-form/react-final-form-arrays

Matt Byrne
  • 4,908
  • 3
  • 35
  • 52