fix console error with FindDOMNode() on unmounted component

This commit is contained in:
KDSBrowne 2017-06-10 11:22:54 -07:00
parent ae883f1065
commit 01a250e5b7

View File

@ -105,13 +105,15 @@ class Dropdown extends Component {
}
handleWindowClick(event) {
const dropdownElement = findDOMNode(this);
const shouldUpdateState = event.target !== dropdownElement &&
if(this.state.isOpen){
const dropdownElement = findDOMNode(this);
const shouldUpdateState = event.target !== dropdownElement &&
!dropdownElement.contains(event.target) &&
this.state.isOpen;
if (shouldUpdateState) {
this.handleHide();
if (shouldUpdateState) {
this.handleHide();
}
}
}