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.

Enhancement request: `formState.dirty`

See original GitHub issue

Is your feature request related to a problem? Please describe. All of our forms will be listening to the formState.dirty value to show a disabled/enabled save button. The issue I’m currently having is for example I focus an input and blur, the form will be set to dirty while the value haven’t changed. The same behaviour happens if my default value was “hi” then I set it to “hey” and changed back that value to “hi”.

Describe the solution you’d like I’d like that the formState.dirty property correspond to a check of defaultValues VS current values. If the object doesn’t match then the property is set to true. That would allow the users to know if they need to save the form because they have changed something while focusing and blurring an input, nothing have changed.

Describe alternatives you’ve considered Is this something I would need to implement on my side or would that be a useful feature enhancement to have on the library?

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
bluebill1049commented, Aug 23, 2019

@tombertrand I will update you here once we release the patch, we are blocked by one of the type improvement, once that’s sorted we will let it out 😃

1reaction
tombertrandcommented, Aug 22, 2019

3.22.2-beta.4 did fix the issue with keys containing ' thanks again for your help 👍

so I ended up doing

const onSubmit = formData => {
  saveItem(formData).then(({ data }) => {
    reset(data);
  });
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

react-hook-form.dirty JavaScript and Node.js code examples
Simplified HTTP request client. bluebird. Full featured Promises/A+ implementation with exceptionally good performance. axios. Promise based HTTP client for the ...
Read more >
Form data loss prevention in React | by Evan Williams - Medium
In the event of the form being submitted, the form is still deemed dirty within form state. Subsequent changes, therefore do not ...
Read more >
useFormState - Simple React forms validation
Dirty fields will not represent as isDirty formState, because dirty fields are marked field dirty at field level rather the entire form.
Read more >
React Hook Form - Reset form with default values and clear ...
... reset, formState } = useForm(formOptions); const { errors } = formState; // user state for form const [user, setUser] = useState(null); ...
Read more >
React Hook Form - A Complete Guide - Hygraph
The useForm hook provides a formState property which gives us more ... any value inside the text input, then only it is marked...
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