title: How can I reset form after submit in reactjs hooks
body: <p>this is my first time using hooks  I don't know How can I clear input fields after submit, form.reset() doesn't work</p>
  <pre><code>import { useForm } from &quot;react-hook-form&quot;;
  import....
  
  export default function AddUser() {
    const URL = &quot;http://localhost:3000/AddUser&quot;;
    const { register, handleSubmit, errors } = useForm();
  
    const onSubmit = (data) =&gt; {
      if (data) {
        axios.post(URL, data);
      }
  form.reset()
    };
  
  </code></pre>
  <p>here is the return part</p>
  <pre><code>  return (
        &lt;form onSubmit={handleSubmit(onSubmit)} noValidate&gt;
          &lt;div className=&quot;container&quot;&gt;
                &lt;input type=&quot;text&quot; name=&quot;name&quot; placeholder=&quot;Name&quot; ref={register({required: true})}/&gt; 
  
                &lt;input type=&quot;radio&quot; name=&quot;gender&quot; value=&quot;male&quot; ref={register({ required: true })}/&gt;:Male
  
                &lt;input type=&quot;radio&quot; name=&quot;gender&quot; value=&quot;female&quot; ref={register({ required: true })}/:Female
              &lt;button type=&quot;submit&quot; className=&quot;btn &quot;&gt; add&lt;/button&gt;
          &lt;/div&gt;
        &lt;/form&gt;
    );
  }
  </code></pre>
  <p>thanks in advance</p>
  <p>//////////</p>
  <p><a href="https://i.stack.imgur.com/ITn8i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ITn8i.png" alt="here is the error when I use form.reset()" /></a></p>