title: how useState really work when state change and state not change
body: <p>I test some code and make me confused</p>
  <p>There are two reproduction,</p>
  <ol>
  <li>use setState function set State to same previous state value</li>
  </ol>
  <pre><code>const [state, setState] = useState(1)
  setState(() =&gt; 1)
  </code></pre>
  <ol start="2">
  <li>use setState function set State to same value(always same ex: 1, true, something else), but different initial state</li>
  </ol>
  <pre><code>const [state, setState] = useState(1)
  setState(() =&gt; 2)
  </code></pre>
  <hr />
  <p>This is reproduction sample 1</p>
  <p><a href="https://codesandbox.io/s/same-4fw0c?file=/src/App.js" rel="nofollow noreferrer">always set state to same value</a></p>
  <p>open codesandbox console first and clear it first.</p>
  <p>what happened</p>
  <p>click, state is already 1, setState function set state to 1,</p>
  <p>component function does not re-run</p>
  <pre><code>// console show 
  test 
  test
  test
  </code></pre>
  <hr />
  <p>This is reproduction  sample 2</p>
  <p><a href="https://codesandbox.io/s/show-u1316?file=/src/index.js" rel="nofollow noreferrer">set state to certain value</a></p>
  <p>I always set state to 2.</p>
  <p>First click, state is change from 1 to 2, so component function re-run</p>
  <pre><code>// console
  test
  app
  </code></pre>
  <p>Second click, <strong>state already is 2</strong>, but why component function still re-run</p>
  <pre><code>// console 
  test 
  app   &lt;--------------  here component function re-run
  </code></pre>
  <p>Third click, state already is 2 , component function does not re-run</p>
  <pre><code>// console 
  test 
  </code></pre>
  <hr />
  <p><strong>The Problem is Here</strong></p>
  <p>In Sample 2, second click button, state is same as
  previous, but is still re-run component.</p>
  <p>And we go back to see Sample 1 and third click in Sample 2, these two state change step is same as Sample 2 second click, they are all same set same state compare to previous state, but how they output is different</p>
  <p>As I know, state change will cause component function re-run.</p>
  <p>What I expect is Sample 2 second click, component function is not re-run</p>