final-form / react-final-form-arrays

A component for rendering and editing arrays 🏁 React Final Form
MIT License
205 stars 70 forks source link

Improve and fix types of value in `useFieldArray` #174

Open iamdey opened 2 years ago

iamdey commented 2 years ago

I found that value is not always defined, I added tests as proof and improve typing as well.


@erikras, may I take the opportunity to ask if Final Form will be maintained ? I find the library pretty cool, there some flaws in the design (cf. issues on the react final form repository), and I recently made a long comparison for our form framework migration since redux-form is deprecated. I hope I can publish it soon. Long story short: coming from redux-form, Final Form is light-weight, fast, and easy to learn, it only miss popularity on github.

peruukki commented 1 year ago

This seems even more relevant now that final-form-arrays v3.1.0 sets the value to undefined:

Change remove and removeBatch behavior to set array value to undefined when all items have been removed.

I was about to create an issue about this but then noticed this pull request. 🙂

raghavsharma-simpplr commented 3 months ago

@iamdey, IMO we should be adding a generic type too. I have a use case,

const {
    fields: { value },
  } = useFieldArray('options[0]');

Where value will now be { label: string; value: string }, shouldn't we have a generic type too?

@erikras should I open a pull request? Without the proper type I have to enforce it manually 😞