title: How to set type of variable on useState using typescript?
body: <p>I created a variable named text and a hook named setText. I'm using it to change the value of a form input field.</p>
  <p>How could I set that text will be of type string?</p>
  <p>Here's what I did try:</p>
  <pre><code>interface TextInterface {
    text: string | null,
    setText: (value: string) =&gt; void,
  }
  
  const [ text, setText ] = useState&lt;TextInterface&gt;('');
  </code></pre>
  <p>But when doing it the following error is displayed: Argument of type 'string' is not assignable to parameter of type 'TextInterface | (() =&gt; TextInterface)'.</p>
  <p>It also display errors inside the input field and inside the handleText function (used on onchange inside input field).</p>
  <p>The function:</p>
  <pre><code>const handleText = (e: React.FocusEvent&lt;HTMLInputElement&gt;): void =&gt; {
      setText(e.currentTarget.value);
  }
  </code></pre>
  <p>That displays the error: Argument of type 'string' is not assignable to parameter of type 'SetStateAction'</p>
  <p>The input field:</p>
  <pre><code>&lt;input type=&quot;text&quot; value={ text } onChange={ handleText } /&gt;
  </code></pre>
  <p>Error:Type 'TextInterface' is not assignable to type 'string | number | readonly string[] | undefined'.</p>