Skip to content

Commit

Permalink
[fixed] Clear the closeWithTimeout timer before unmounting
Browse files Browse the repository at this point in the history
  • Loading branch information
ewiner committed Jul 22, 2015
1 parent 0d5e76a commit 02cf2c3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/components/ModalPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ var ModalPortal = module.exports = React.createClass({
}
},

componentWillUnmount: function() {
clearTimeout(this.closeTimer);
},

componentWillReceiveProps: function(newProps) {
// Focus only needs to be set once when the modal is being opened
if (!this.props.isOpen && newProps.isOpen) {
Expand Down Expand Up @@ -87,7 +91,7 @@ var ModalPortal = module.exports = React.createClass({

closeWithTimeout: function() {
this.setState({beforeClose: true}, function() {
setTimeout(this.closeWithoutTimeout, this.props.closeTimeoutMS);
this.closeTimer = setTimeout(this.closeWithoutTimeout, this.props.closeTimeoutMS);
}.bind(this));
},

Expand Down

0 comments on commit 02cf2c3

Please sign in to comment.