Skip to content

How can I get all values of dirtyfield? #3275

Answered by jordanwallwork
goffxnca asked this question in Q&A
Discussion options

You must be logged in to vote

Could you do something like the following?

const { register, handleSubmit, formState, getValues } = useForm();
const dirtyFields = Object.keys(formState.dirtyFields).map((x) => ({
  field: x,
  value: getValues(x)
}));`

https://codesandbox.io/s/dirty-field-values-hqg3j?file=/src/index.js

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@goffxnca
Comment options

@jonybekov
Comment options

@stychu
Comment options

@uttampun44
Comment options

Answer selected by bluebill1049
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants