title: How to go to last element in react?
body: <p>I tried <code>scrollIntoView</code> and used <code>.lastchild</code> but I can't go to the latest comment. Used <code>window.scrollTo</code> too can't find any solution.</p>
  <p>Can anyone have some suggestions on what will work?</p>
  <pre><code>     const click = () =&gt; {
                  fetch('url')
                  .then(res =&gt; res.json())
                  .then(data =&gt; {
                      if (data.affectedRows &gt; 0) {
                         var element = document.getElementById(&quot;txt&quot;).lastChild;
                          element.scrollIntoView({behavior: &quot;smooth&quot;, block: &quot;end&quot;, inline: &quot;center&quot;});
                   }
              })
          }         
  }
  
   {getComment.map(cmnt =&gt;
                          &lt;div key={cmnt.comment_id} className=&quot;article-comments-reply&quot;&gt;
                              &lt;div className=&quot;text-box&quot; id=&quot;txt&quot;&gt;
                                  &lt;h3&gt;{cmnt.username}&lt;/h3&gt;
                                  &lt;div className=&quot;reply-box&quot;&gt;
                                      &lt;h4&gt;{cmnt.comment_text}&lt;/h4&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  )}
  </code></pre>