-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
FieldArray length wrong when using remove()
and getValues
with shouldActive: false
#105
Comments
reset()
and getValues
with shouldActive: false
remove()
and getValues
with shouldActive: false
Thanks for creating the issue and your feedback. I am in the process of revising the technical implementation of the |
However, I have already fixed some of the problems. Please test the whole thing once in the latest version. The length should work according to my tests. |
Thank you, I will give the newest version a try :) |
Yes, the newest version fixes that issue! One question though: When I remove an item from an array via |
Yes, field arrays also have their own |
Well, I don't know; it seems very case specific. I'll try to explain my usecase: I have a Currently I use I was thinking of using a custom diff function. I could remove Or do you have any other ideas how to solve the problem? |
Yes, you can use |
It seems the issue happens because I've reproduced the issue in both solid and preact but the same line exists in all packages (solid, qwik, react, preact). To reproduce the issue in the linked stackblitz:First, click one of the "Remove item" buttons to interact with the form's Now click "Set values" and again remove one of the items in the list. Now click submit and you'll see 2 I've submitted #274 which seems to fix the issue based on local testing. This might also be related to #85. |
Sorry for the late reply. I'll try to look at it next week, but I can't guarantee it with so many other things going on at the moment. 😐 |
I stubled upon a strange behaviour, which seems like a bug to me.
The form that I am using is quite big and contains a bunch of ArrayFields, of which not all are rendered at the same time.
Since I want to always get all the values, regardless of whether they are rendered or not, I am using
shouldActive: false
wherever possible, as per your recommendation.Now, when I remove an entry from the FieldArray via
remove
, I was expecting that entry to be deleted from the form store.But it seems that that is only the case when getting the values via with
shouldActive: true
. WithshouldActive: false
the number of items is wrong.Reproduction:
https://stackblitz.com/edit/github-uzqzot-m1rwea?file=src%2FApp.tsx
Coming from react and Formik (with the desire to switch to react-hook-form) I really like your plugin and the philosophy behind it! Thanks for the great work! 👍
But there is one thing that regularly kills my productivity:
I cannot seem to find a way of how to reliably interact with the field store and the values inside. I don't know if it is related to concept of
active
ness of a field, but each,reset
,remove
(this issue) andinsert
(could't fully reproduce my problem there) already caused problems to me, even when trying to opt out of that behaviour.The text was updated successfully, but these errors were encountered: