Overriding DefaultValues if form is dirty
See original GitHub issueDescribe the bug
When using register
to provide DefaultValues to an input, it’s possible that the input component will be removed from the virtual DOM and eventually re-added. Upon re-rendering, register
will initialize the input as the DefaultValue, even if the form state has been changed (dirty)
Expected behavior
register
could be able to use the most recent form state, instead of reverting to DefaultValues.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How do I override the defaultValues in useForm and maintain ...
I considered setValues but I want to use the isDirty function, which allows field validation and the value used to check whether the...
Read more >Is there a way to track whether fields are dirty after the default ...
When the component is in "edit" mode I set the default values ... team data and then use reset() to overwrite the initial...
Read more >Uncontrolled Components - React
In a controlled component, form data is handled by a React component. ... It can also be slightly less code if you want...
Read more >useForm - FormState - Simple React forms validation
Make sure to provide all inputs' defaultValues at the useForm, so hook form can have a single source of truth to compare whether...
Read more >React-admin - The Creation and Edition Pages - Marmelab
Alternatively, you can specify a defaultValue prop directly in <Input> components. React-admin will ignore these default values if the Form already defines ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@marracheco this is how we building wizzard form at work
Each page renders itself and during submission, it will update the data in the store.
@marracheco would you like to send a PR for your Wizzard example? we can have it under example folder. (keep it simple so devs can pick up the idea)