I have a component called Dialog, in which I attach an event listener on mouse clicks on the window object.
componentDidMount() {
    document.addEventListener('click', this.handleClick);
}
componentWillUnmount() {
    document.removeEventListener('click', this.handleClick);
}
How can I detect (in the handleClick function) whether a click has been fired inside the component or outside? Note that this dialog contains different elements and child components.
 
    