From 02cf2c342bcf678c6442eb7db85fefd1900882ff Mon Sep 17 00:00:00 2001 From: Eric Winer Date: Tue, 21 Jul 2015 20:02:41 -0400 Subject: [PATCH] [fixed] Clear the closeWithTimeout timer before unmounting --- lib/components/ModalPortal.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)); },