title: React JS ref (useRef): contains is not a function
body: <p>I am working on a React JS project. I am using hooks and functional components. I am using ref. I am using useRef because I am in a functional component. But the contains function is not working on ref. Following is my code.</p>
  <pre><code>const App = () =&gt; {
      let refDialog = useRef(null);
      
      document.addEventListener('click', (e) =&gt; {
        if (refDialog &amp;&amp; refDialog.contains(e.target)) {
           // I will do something here
        }
      })
     
      return (
        &lt;div&gt;
          &lt;Dialog ref={ ref =&gt; refDialog = ref}&gt;My dialog content&lt;/Dialog&gt;
       &lt;/div&gt;
      )
  }
  </code></pre>
  <p>As you can see in my component, in the event listener, it is throwing the following error.</p>
  <pre><code>Uncaught TypeError: refDialog.contains is not a function
  </code></pre>
  <p>What is wrong with my code?</p>