Skip to content

Commit

Permalink
Merge pull request #53 from ewiner/master
Browse files Browse the repository at this point in the history
[fixed] Clear the closeWithTimeout timer before unmounting
  • Loading branch information
mzabriskie committed Sep 11, 2015
2 parents 9e092ae + 02cf2c3 commit acd3c65
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 acd3c65

Please sign in to comment.