Skip to content

Commit

Permalink
[fixed] remove portal context in timeout (reactjs#353)
Browse files Browse the repository at this point in the history
Fixes the binding of the `removePortal` call in the `setTimeout` callback
by capturing a this reference in a variable in the closure scope.
Doesn't use `bind` which apparently causes warnings.

Fixes reactjs#344, fixes reactjs#348
  • Loading branch information
AndersDJohnson authored and claydiffrient committed Mar 11, 2017
1 parent dbaaef2 commit e1df119
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/components/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ var Modal = React.createClass({
this.portal.closeWithTimeout();
}

setTimeout(function() { this.removePortal(); }, closesAt - now);
var that = this;
setTimeout(function() { that.removePortal(); }, closesAt - now);
} else {
this.removePortal();
}
Expand Down

0 comments on commit e1df119

Please sign in to comment.