-
-
Notifications
You must be signed in to change notification settings - Fork 72
Improve and fix types of value in useFieldArray
#174
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
Conversation
`value` can be `undefined` if it has not been initialized.
Note: this is already correctly typed for typescript
peruukki
commented
Apr 13, 2023
This seems even more relevant now that final-form-arrays v3.1.0 sets the value to undefined
:
Change
remove
andremoveBatch
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. 🙂
@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 😞
Uh oh!
There was an error while loading. Please reload this page.
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.