title: How to use react-hook-form inside class Component?
body: <p>I use the following code to create a login page with form validation:</p>
  <pre><code>import React from 'react';
  import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
  import { useForm } from 'react-hook-form';
  
  class SignIn extends React.Component {
    
  const { register, handleSubmit, errors } = useForm();
  const onSubmit = data =&gt; console.log(data);
  console.log(errors);
  
    render() {
      return (
        &lt;div&gt;
          &lt;Form onSubmit={handleSubmit(onSubmit)}&gt;
  
              &lt;Label&gt;Email : &lt;/Label&gt;
              &lt;Input type=&quot;email&quot; placeholder=&quot;email&quot; name=&quot;email&quot; ref={register({required: true, pattern: /^\S+@\S+$/i})}&gt;&lt;/Input&gt;
  
              &lt;Label&gt;Password : &lt;/Label&gt;
              &lt;Input type=&quot;password&quot; placeholder=&quot;password&quot;  name=&quot;password&quot; ref={register({required: true, min: 8, maxLength: 20})}&gt;&lt;/Input&gt;
  
          &lt;/Form&gt;
        &lt;/div&gt;
      );
    }
  }
  
  
  export default SignIn;
  
  </code></pre>
  <p>and I have a problem using react-hook-form inside the Class Component
  <BR>
  My question, if it's possible, is: How to use the react-hook-form with Class Component without rewriting the code to the hook version?</p>