Skip to content

FieldArray length wrong when using remove() and getValues with shouldActive: false #105

Open
@whytspace

Description

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. With shouldActive: 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 activeness of a field, but each, reset, remove (this issue) and insert (could't fully reproduce my problem there) already caused problems to me, even when trying to opt out of that behaviour.

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions