diff --git a/lib/components/ModalPortal.js b/lib/components/ModalPortal.js index 276d4606..fb1644af 100644 --- a/lib/components/ModalPortal.js +++ b/lib/components/ModalPortal.js @@ -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) { @@ -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)); },