Skip to content

Commit

Permalink
Adding isMounted checks in timeouts for safety
Browse files Browse the repository at this point in the history
  • Loading branch information
JedWatson committed Sep 30, 2015
1 parent f21ee5c commit 7684869
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ var Select = React.createClass({
clearTimeout(this._blurTimeout);
clearTimeout(this._focusTimeout);
this._focusTimeout = setTimeout(() => {
if (!this.isMounted()) return;
this.getInputNode().focus();
this._focusAfterUpdate = false;
}, 50);
Expand Down Expand Up @@ -426,7 +427,7 @@ var Select = React.createClass({

handleInputBlur (event) {
this._blurTimeout = setTimeout(() => {
if (this._focusAfterUpdate) return;
if (this._focusAfterUpdate || !this.isMounted()) return;
this.setState({
isFocused: false,
isOpen: false
Expand Down

0 comments on commit 7684869

Please sign in to comment.