title: React - call two methods, but only last method logout is called
body: <p>I am calling this message after success, I want to call success message first and then logout. But currently, only logout is called and it signed out.</p>
  <pre><code> const [success, setSuccess] = useState(false);
  
    const message = useCallback(
      () =&gt; {
        msg('successfully');
        logout();
      },
      [success, logout],
    );
  
  return (
      &lt;&gt;
        {success &amp;&amp; message()}
  </code></pre>