I have a component called Dialog in which I attach an event listener to mouse clicks on a 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 handleClick inside the component or outside? Note that this dialog box contains various elements and child components.
reactjs
Matthew
source share