title: Detecting when user scrolls to bottom of div with React js
body: <p>I have a website with different sections. I am using segment.io to track different actions on the page. How can I detect if a user has scrolled to the bottom of a div? I have tried the following but it seems to be triggered as soon as I scroll on the page and not when 
   I reached the bottom of the div.</p>
  
  <pre><code>componentDidMount() {
    document.addEventListener('scroll', this.trackScrolling);
  }
  
  trackScrolling = () =&gt; {
    const wrappedElement = document.getElementById('header');
    if (wrappedElement.scrollHeight - wrappedElement.scrollTop === wrappedElement.clientHeight) {
      console.log('header bottom reached');
      document.removeEventListener('scroll', this.trackScrolling);
    }
  };
  </code></pre>