title: function without () in useState (react hook)
body: <p>When I pass function parameter to useState() like this:</p>
  
  <pre><code>const [testA, setTestA] = useState(returnTestA());  // run every rendering
  const [testB, setTestB] = useState(returnTestB); // run only mount
  </code></pre>
  
  <ul>
  <li>function with () is run every rendering </li>
  <li>but function without () is run only first rendering(mount) </li>
  </ul>
  
  <p>It is my whole code: (<code>info.js</code>)</p>
  
  <pre><code>import React, { useState } from "react";
  
  let count = 0;
  
  const returnTestA = () =&gt; {
    count++;
    console.log("test A: " + count);
    return "test";
  };
  
  const returnTestB = () =&gt; {
    count++;
    console.log("test B: " + count);
    return "test";
  };
  
  const Info = () =&gt; {
    const [name, setName] = useState("");
    const [testA, setTestA] = useState(returnTestA());  // run every rendering
    const [testB, setTestB] = useState(returnTestB); // run only mount
  
    const onChangeName = e =&gt; {
      setName(e.target.value);
    };
  
    return (
      &lt;div&gt;
        &lt;div&gt;
          &lt;input name="name" value={name} onChange={onChangeName} /&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;b&gt;Name:&lt;/b&gt; {name}
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    );
  };
  
  export default Info;
  </code></pre>
  
  <p>the result is: </p>
  
  <ol>
  <li><p>just npm start:
  <a href="https://i.stack.imgur.com/o8p7q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o8p7q.png" alt="npm_start"></a></p></li>
  <li><p>type something in input:
  <a href="https://i.stack.imgur.com/7Dmyi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Dmyi.png" alt="type_something"></a></p></li>
  </ol>
  
  <p>Why It happened?? And what is the best practice?</p>