title: Set default values in React Hook Form
body: <p>I want to check in a RHF if the user has modified the form values with the <code>isDirty</code> parameter.</p>
  <p>Setting the defaultValues manually works:</p>
  <pre><code>const {handleSubmit, control, setValue, setError, setFocus} = useForm({defaultValues: {name: &quot;&quot;}});
  </code></pre>
  <p>This seem to work correctly.</p>
  <p>But when the user tries to edit a form I load the values into the form with <code>setValue</code>.</p>
  <p>Now I don't know how I can set programatically the defaultValues.</p>
  <p><a href="https://stackoverflow.com/questions/62242657/how-to-change-react-hook-form-defaultvalue-with-useeffect/62243132#62243132">How to change React-Hook-Form defaultValue with useEffect()?</a></p>
  <p>This is how I do, but the answer is not really correct. The values are set, but the defaultValues don't change this way so RHF can't compare.</p>
  <blockquote>
  <p>Make sure to provide all inputs' defaultValues at the useForm, so hook form can have a single source of truth to compare whether the form is dirty.</p>
  </blockquote>
  <p><a href="https://react-hook-form.com/api/useform/formstate" rel="nofollow noreferrer">https://react-hook-form.com/api/useform/formstate</a></p>
  <p>How can I set the defaultValues dynamically so it even works in 'edit' mode?</p>