You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to use this with useFieldArray, the value in the form state immediately becomes an empty array. This leads to the form being marked as dirty, which is not good for our use case.
Question: Is there a way to handle nullable arrays without the form spuriously being marked as dirty, or do we have to make sure our model does not include nullable arrays?
I haven't been able to find much about this in docs etc, the clearest answer I've seen is in this discussion.
Below is a full reproduction, where we see that values.listField and defaultValues.listField are immediately different. If we remove the line with useFieldArray they are both null.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Example type and default values:
When trying to use this with
useFieldArray, the value in the form state immediately becomes an empty array. This leads to the form being marked as dirty, which is not good for our use case.Question: Is there a way to handle nullable arrays without the form spuriously being marked as dirty, or do we have to make sure our model does not include nullable arrays?
I haven't been able to find much about this in docs etc, the clearest answer I've seen is in this discussion.
Below is a full reproduction, where we see that
values.listFieldanddefaultValues.listFieldare immediately different. If we remove the line withuseFieldArraythey are both null.Beta Was this translation helpful? Give feedback.
All reactions