title: How to increment a value using onClick in react
body: <p>I have a button when pressed onClick triggers <code>LikeComment</code> which posts the like to a DataBase using the current comment id and user who posted the comment.</p>
  <pre><code>    &lt;button className=&quot;btn&quot; onClick={LikeComment(comment_id, user_id)}&gt;
        &lt;div className=&quot;text&quot;&gt;
          &lt;i className=&quot;fas fa-thumbs-up&quot;&gt;&lt;/i&gt;
          &lt;p&gt;{comment_likes.length}&lt;/p&gt;
        &lt;/div&gt;
      &lt;/button&gt;
  </code></pre>
  <p>What would be the best way to increment <code>comment_likes.length</code> when ever the button is pressed. Right now my problem is that the value only updates when page refreshes.</p>
  <p>I have tried to do this, but It doesn't work as intended</p>
  <pre><code>&lt;p&gt;{comment_likes.length &amp;&amp; LikeComment ? (comment_likes.length+1) : (comment_likes.length)}&lt;/p&gt;
  </code></pre>
  <p>I want to achieve this by detecting when LikeComment is pressed to increment the original value by 1.</p>
  <p>Any tips to tackle this would be appreciated..</p>