react-hook-form: Why dirtyFields not updating if i make any field dirty?

Why dirty fields not updating if I make any field dirty.

Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/7o2wrp86k6
  2. Type into any field.
  3. I expect dirtyFields to update with the field details.
  4. Error: dirtyFields is always empty.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (11 by maintainers)

Most upvoted comments

Screen Shot 2020-04-11 at 2 21 54 pm

updated 😃

I think i need to find a better term to describe the invoke, people probably gets confused.

const { dirty } = formState; // read the individual state before the render

instead of

return <div>{formState.dirty}</div>

Yes it’s due to Proxy: https://react-hook-form.com/api#formState

also dirtyFields is a Set

Screen Shot 2020-04-04 at 9 23 01 am

@bluebill1049 I would like to, however I still don’t understand how to invoke the proxy to get the data to show up properly. In that sandbox dirtyFields is still showing up as an empty object for me {}

If you post a quick example here I can edit the docs

@bluebill1049 Perhaps adding an example read and/or invocation to the documentation there to make that more clear? I’m not exactly sure what ā€œinvokingā€ a Proxy would mean

Screen Shot 2020-03-04 at 3 44 13 pm

please double check your console.