title: How to resolve the error Attempted import error: 'react-hook-form' does not contain a default export (imported as 'useForm'). using react js
body: <p>How to Attempted import error: 'react-hook-form' does not contain a default export (imported as 'useForm'). fix the error using react js. I am try to do that but i am getting error when i run nom start this error 'react-hook-form' does not contain a default export (imported as 'useForm'). fix the error using react js.</p>
  <p>anybody help me out how to fix that.its very thankful</p>
  <p>my code</p>
  <pre><code>import React, { useRef, useState } from &quot;react&quot;;
  import ReactDOM from &quot;react-dom&quot;;
  import useForm from &quot;react-hook-form&quot;;
  
  import &quot;./styles.css&quot;;
  
  function App() {
    const { register, errors, handleSubmit, watch } = useForm({});
    const password = useRef({});
    const newpassword = useRef({});
  
    password.current = watch(&quot;password&quot;, &quot;&quot;);
    newpassword.current = watch(&quot;password_repeat&quot;, &quot;&quot;);
    const onSubmit = async (data) =&gt; {
      if (password.current.length === 0) {
        alert(&quot;You must specify a password&quot;);
        return;
      }
  
      var match = password.current.match(
        /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=[^!&quot;#$%&amp;'()*+,-.:;&lt;=&gt;?@[\]^_`{|}~]*[!&quot;#$%&amp;'()*+,-.:;&lt;=&gt;?@[\]^_`{|}~])(?=\D*\d)/
      );
      if (!match) {
        alert(
          &quot;Password Should contain at least one Number, one upperCase and one lowercase letter and a special character&quot;
        );
        return;
      }
  
      if (password.current.length &lt; 8) {
        alert(&quot;Password must have at least 8 characters&quot;);
        return;
      }
  
      if (newpassword.current !== password.current) {
        alert(&quot;The passwords do not match&quot;);
        return;
      }
  
      alert(&quot;Your Success message&quot;);
    };
  
    return (
      &lt;form onSubmit={(e) =&gt; e.preventDefault()}&gt;
        &lt;label&gt;Password&lt;/label&gt;
        &lt;input name=&quot;password&quot; type=&quot;text&quot; ref={register({})} /&gt;
        {errors.password &amp;&amp; &lt;p&gt;{errors.password.message}&lt;/p&gt;}
  
        &lt;label&gt;Repeat password&lt;/label&gt;
        &lt;input name=&quot;password_repeat&quot; type=&quot;password&quot; ref={register({})} /&gt;
        {errors.password_repeat &amp;&amp; &lt;p&gt;{errors.password_repeat.message}&lt;/p&gt;}
  
        &lt;input type=&quot;submit&quot; onClick={handleSubmit(onSubmit)} /&gt;
      &lt;/form&gt;
    );
  }
  
  const rootElement = document.getElementById(&quot;root&quot;);
  ReactDOM.render(&lt;App /&gt;, rootElement);
  </code></pre>
  <p>My package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;react-hook-form-password-match-check-standard-validation&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;keywords&quot;: [],
    &quot;main&quot;: &quot;src/index.js&quot;,
    &quot;dependencies&quot;: {
      &quot;react&quot;: &quot;16.8.6&quot;,
      &quot;react-dom&quot;: &quot;16.8.6&quot;,
      &quot;react-hook-form&quot;: &quot;3.13.1&quot;,
      &quot;react-scripts&quot;: &quot;3.0.1&quot;
    },
    
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;react-scripts start&quot;,
      &quot;build&quot;: &quot;react-scripts build&quot;,
      &quot;test&quot;: &quot;react-scripts test --env=jsdom&quot;,
      &quot;eject&quot;: &quot;react-scripts eject&quot;
    },
    &quot;browserslist&quot;: [
      &quot;&gt;0.2%&quot;,
      &quot;not dead&quot;,
      &quot;not ie &lt;= 11&quot;,
      &quot;not op_mini all&quot;
    ]
  }
  </code></pre>