title: Using ResizeObserver in React class component
body: <p>I am using React 15 on Chrome and want to hook up an event listener to detect changes to a parent container. After looking around for options, I came across ResizeObserver and am not sure how to get it to work in my project.</p>
  
  <p>Currently, I am putting it in my constructor but it does not seem to print any text and I am not sure what to put in the <code>observe</code> call.</p>
  
  <pre><code>class MyComponent extends React.Component {
      constructor(props) {
          super(props);
  
          const resizeObserver = new ResizeObserver((entries) =&gt; {
              console.log("Hello World");
          });
  
          resizeObserver.observe(somethingGoesHere);
      }
  
      render() {
          return (
              &lt;AnotherComponent&gt;
                  &lt;YetAnotherComponent&gt;
                  &lt;/YetAnotherComponent&gt;
  
                  &lt;CanYouBelieveIt&gt;
                  &lt;/CanYouBelieveIt&gt;
  
                  &lt;RealComponent /&gt;
              &lt;/AnotherComponent&gt;
          );
      }
  }
  </code></pre>
  
  <p>Ideally, I also don't want to wrap <code>RealComponent</code> in a <code>div</code> and give that <code>div</code> an id. Is there a way to the <code>RealComponent</code> directly?</p>
  
  <p>My goal is to observe any resize changes to the <code>RealComponent</code> but <code>MyComponent</code> is fine too. What should I put in the <code>somethingGoesHere</code> slot?</p>
  
  <p>EDIT: </p>
  
  <p>For the sake of getting something to work, I bit the bullet and wrapped a <code>div</code> tag around <code>RealComponent</code>. I then gave it an id <code>&lt;div id="myDivTag"&gt;</code> and changed the <code>observe</code> call:</p>
  
  <pre><code>resizeObserver.observe(document.getElementById("myDivTag"));
  </code></pre>
  
  <p>However, when running this, I get: </p>
  
  <blockquote>
    <p>Uncaught TypeError: resizeObserver.observe is not a function</p>
  </blockquote>
  
  <p>Any help would be greatly appreciated.</p>