Skip to content
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

Improve and fix types of value in useFieldArray #174

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

iamdey
Copy link

@iamdey iamdey commented Nov 8, 2022

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.

`value` can be `undefined` if it has not been initialized.
Note: this is already correctly typed for typescript
@peruukki
Copy link

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
Copy link

raghavsharma-simpplr commented Aug 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants