Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/OutsideClickHandler.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ export default class OutsideClickHandler extends React.Component {
this.onMouseDown = this.onMouseDown.bind(this);
this.onMouseUp = this.onMouseUp.bind(this);
this.setChildNodeRef = this.setChildNodeRef.bind(this);
this._isMounted = false;
}

componentDidMount() {
this._isMounted = true;
const { disabled, useCapture } = this.props;

if (!disabled) this.addMouseDownEventListener(useCapture);
Expand All @@ -57,6 +59,7 @@ export default class OutsideClickHandler extends React.Component {
}

componentWillUnmount() {
this._isMounted = false;
this.removeEventListeners();
}

Expand Down Expand Up @@ -87,7 +90,7 @@ export default class OutsideClickHandler extends React.Component {
if (this.removeMouseUp) this.removeMouseUp();
this.removeMouseUp = null;

if (!isDescendantOfRoot) {
if (this._isMounted && !isDescendantOfRoot) {
onOutsideClick(e);
}
}
Expand Down