Answer the question
In order to leave comments, you need to log in
How to handle click outside react component?
The first thing that comes to mind is a solution
document.addEventListener('click', this.handleOuterClick);
handleOuterClick: function(e) {
let $node = $(ReactDOM.findDOMNode(this);
if ($node.has(e.target).length === 0) {
/*
* some actions
* */
}
}
Answer the question
In order to leave comments, you need to log in
That's pretty much how they do it.
https://www.npmjs.com/package/react-click-outside
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question