question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a way to disable merging of `defaultValues` into submission results

See original GitHub issue

Is your feature request related to a problem? Please describe. V7 introduced a new feature to merge defaultValues into submission result.

This would break the logic for many use cases including dynamically generated fields. If the defaultValue includes mobileNumbers[3] and the user delete that particular mobile number, the submission results would include the number that user intended to delete which renders the deletion useless.

Describe the solution you’d like A way to disable the merging by default. At the moment, I cannot keep using V7 because there is absolutely no way to extract the actual state of the form. Because defaultValues is canceling all the deletions.

Describe alternatives you’ve considered Since getValues, watch, and handleSubmit is also affected, there is no way to extract the actual data. If there is an alternative, I can’t see it.

Additional context I understand users voted for this feature, but I think it does more harms than good. Merging the result is such an easy thing that users would be able to make a decision themselves and implement it in their code. I don’t really think the library should be in charge of making this decision. At least there should be a way to disable it.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:39 (38 by maintainers)

github_iconTop GitHub Comments

3reactions
bluebill1049commented, Apr 18, 2021

Going to do an RFC on this one after shouldUnregister, my purpose is to have a config at useForm to turn on and off the behavior.

useForm({
  shouldIncludeDefaults: true, // or shouldMergeDefaults
})

let me know your guys’ early thoughts on this.

2reactions
bmamouricommented, Apr 25, 2021

Hey @bluebill1049, Sorry I was looking at the wrong part of the doc. It is actually wokring properly. Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enable or disable form merging - Microsoft Support
If you enable form merging for a form template, your users can consolidate data from many different forms that are based on that...
Read more >
How to display defaultValues with useFieldArray hook in ...
I would like to have a field array that can be generated by the user by adding an infinite number of key/value pairs...
Read more >
Set Default Merge Values for an Audience - Mailchimp
From the audience settings · Click Audience. · Click Audience dashboard. · In the fields in the Default value column, type the default...
Read more >
React Query and Forms | TkDodo's blog
We fetch the firstName and lastName, put it into the form state, and then ... all you need to do is to disable...
Read more >
How to Combine Pattern Constraints and Default Values for ...
That filters the foo function argument according to a Positive predicate and an Integer Head and provides in the same time a default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found