issue: isDirty not updating with field array/controlled input #10796
-
Version Number7.43.9 Codesandbox/Expo snackhttps://codesandbox.io/s/modest-lucy-cq2y7j?file=/src/App.tsx Steps to reproduce
Expected behaviourShould see in console output that formState.isDirty is true and formState.dirtyFields has dirtied input. You will see that isDirty and dirtyFields will be false and not have the modified input. If you modify the input again and then click submit again, you will see isDirty and dirtyFields is updated to be true and have the modified input. What browsers are you seeing the problem on?No response Relevant log outputNo response Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
![]() working as expected, and the form state is on each render. |
Beta Was this translation helpful? Give feedback.
-
Alright, I understand now why the formState isn't updating since it is wrapped in a proxy and nothing is using formState during render. Is there a way to get an updated formState on the onSubmit callback without having to use formState somewhere in the render? I would like to do some logic based on if certain fields are dirty or not during submit. At the moment I have a workaround of manually calling form.trigger() to update the formState. This seems to work but not sure if that is a good solution. |
Beta Was this translation helpful? Give feedback.
We did formState with proxy to prevent re-render, if a user is not subscribed to the particular formState.
form.trigger()
that's fine, but it would validate the entire form. (if you concerns about the perf)