title: Cannot read property 'scrollIntoView' of undefined in Reactjs
body: <p>I am trying to scroll div to button when page loaded and  added a new message in the list.</p>
  
  <p>but here I am getting error 'scrollIntoView' undefined.</p>
  
  <p>This is my code what I have tried so far</p>
  
  <pre><code>     componentDidUpdate() {
         this.scrollToBottom ()
        }
  
       componentDidMount() {
         this.scrollToBottom ()
        }
  
         scrollToBottom = () =&gt; {
        this.messagesEnd.scrollIntoView({ behavior: "smooth",  });
       } 
    &lt;div style={{ float:"left", clear: "both" }}
    ref={(el) =&gt; (this.messagesEnd = el)}&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>what Is wrong here why it is showing this error.</p>
  
  <p>Your help would be highly appropriated </p>