New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue: reset() resets dirty values even though keepDirtyValues is set to true #11514
Comments
It is totally possible that I am missing something. About the needed subscription of So happy to hear that I am doing something wrong but it might be bug as well. |
I also tried using This also doesn't seem to work like I would read it from the docs https://react-hook-form.com/docs/useform/resetfield I provided the new defaultValue for the field but it doesn't set neither the default nor the value. I'm trying to set an array of objects, if that makes a difference |
i just tried your demo, keepDirtyValues should be it and it's working in your link as well. let me know what's the issue and I will take a look at it agian. |
After the reset the input UI still shows the correct value. But the firstName in formValues is reset to it's default of Make sure to enter a firstName before the 5s timeout or reload the demo browser in case you passed the timeout. Look at Initial state "firstName": "" After manual update of input field "firstName": "Tyler" After fake loading timeout "firstName": "" (Other fields are correctly set to new default values) |
… field names with keepDirtyValues
…e reset mounted field names with keepDirtyValues (react-hook-form#11546)
Version Number
7.50.1
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/condescending-forest-8wk8v2?file=%2Fsrc%2FApp.tsx%3A15%2C10
Steps to reproduce
keepDirtyValues: true
is set (and the dirtyFields is also subscribed by destructuring it)Expected behaviour
The firstName field value should not be reset
What browsers are you seeing the problem on?
No response
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: