title: Correct way to type a 'setState' function using React hook useState()
body: <p>I'm working with React and typescript and just stumbled upon a dilemma. I use <code>React.useState()</code> hook to manage my state like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>const [currentUser, setCurrentUser] = React.useState({} as User)  // currentUser is of type User
  </code></pre>
  
  <p>I found this way to type the <code>setCurrentUser</code> function:</p>
  
  <pre class="lang-js prettyprint-override"><code>setCurrentUser: React.Dispatch&lt;React.SetStateAction&lt;User&gt;&gt;
  </code></pre>
  
  <p>So if I try to use this function with an invalid parameter like a string I get this error:</p>
  
  <blockquote>
    <p><code>Argument of type '"dummy string"' is not assignable to parameter of type 'SetStateAction&lt;User&gt;'</code></p>
  </blockquote>
  
  <p>Then I found an easier way:</p>
  
  <pre class="lang-js prettyprint-override"><code>setCurrentUser: React.Dispatch&lt;User&gt;
  </code></pre>
  
  <p>With this way the error message is easier to read too:</p>
  
  <blockquote>
    <p><code>Argument of type '"dummy string"' is not assignable to parameter of type 'User'</code></p>
  </blockquote>
  
  <p>So witch one is the correct/official way to type this <code>setState</code> hook function ?</p>