Skip to content

Commit 02cf2c3

Browse files
committed
[fixed] Clear the closeWithTimeout timer before unmounting
1 parent 0d5e76a commit 02cf2c3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: lib/components/ModalPortal.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ var ModalPortal = module.exports = React.createClass({
4343
}
4444
},
4545

46+
componentWillUnmount: function() {
47+
clearTimeout(this.closeTimer);
48+
},
49+
4650
componentWillReceiveProps: function(newProps) {
4751
// Focus only needs to be set once when the modal is being opened
4852
if (!this.props.isOpen && newProps.isOpen) {
@@ -87,7 +91,7 @@ var ModalPortal = module.exports = React.createClass({
8791

8892
closeWithTimeout: function() {
8993
this.setState({beforeClose: true}, function() {
90-
setTimeout(this.closeWithoutTimeout, this.props.closeTimeoutMS);
94+
this.closeTimer = setTimeout(this.closeWithoutTimeout, this.props.closeTimeoutMS);
9195
}.bind(this));
9296
},
9397

0 commit comments

Comments
 (0)