issue: isDirty keep false after reset - using Field Array and append with class object #10678
-
Version Number7.45.1 Codesandbox/Expo snackhttps://codesandbox.io/s/fieldarraytest-rnmhpf Steps to reproduceIn the code sandbox
Note: There is problem when the append is added with class object no problem when the append is using plain object Expected behaviour
What browsers are you seeing the problem on?Chrome, Safari Relevant log outputFrom the log, the defaultValue is changed when input text in step
CardIndex | dirty false, valid true, state: {"defaultValues":{"list":[{"firstName":"42342344444","lastName":"423423"}]}}touchedFields: {"list":[{"firstName":true,"lastName":true}]} dirtyFields: {}
....
CardIndex | dirty false, valid true, state: {"defaultValues":{"list":[{"firstName":"423423","lastName":"423423"}]}}touchedFields: {"list":[{"firstName":true,"lastName":true}]} dirtyFields: {} Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Not sure why you need to use class object for field array but it will not be compatible with clone value handling from react-hook-form. The fallback for case cloning is not possible will be return the original object and that is the root cause of wrong dirty check. You need to transform class object into plain javascript object before put it into |
Beta Was this translation helpful? Give feedback.
@jeffwong14
Not sure why you need to use class object for field array but it will not be compatible with clone value handling from react-hook-form. The fallback for case cloning is not possible will be return the original object and that is the root cause of wrong dirty check.
You need to transform class object into plain javascript object before put it into
append
method.