How do I check if the user clicked inside the current component?
<p>I have a component called <code>Dialog</code>, in which I attach an event listener on mouse clicks on the <code>window</code> object.</p>

<pre><code>componentDidMount() {
    document.addEventListener('click', this.handleClick);
}

componentWillUnmount() {
    document.removeEventListener('click', this.handleClick);
}
</code></pre>

<p>How can I detect (in the <code>handleClick</code> function) whether a click has been fired inside the component or outside? Note that this dialog contains different elements and child components.</p>