From a9b8ca027cfcb43fca8396496dceb094d488405f Mon Sep 17 00:00:00 2001 From: Dral Date: Sat, 3 Oct 2015 11:45:28 -0700 Subject: [PATCH] Clear timeouts on unmount in TouchableMixin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Fixes #1152 Closes https://github.com/facebook/react-native/pull/3176 Reviewed By: @​svcscm Differential Revision: D2506385 Pulled By: @vjeux --- .../react_contrib/interactions/Touchable/Touchable.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Libraries/vendor/react_contrib/interactions/Touchable/Touchable.js b/Libraries/vendor/react_contrib/interactions/Touchable/Touchable.js index 93c4a7b59..3ff08f736 100644 --- a/Libraries/vendor/react_contrib/interactions/Touchable/Touchable.js +++ b/Libraries/vendor/react_contrib/interactions/Touchable/Touchable.js @@ -303,6 +303,15 @@ var LONG_PRESS_ALLOWED_MOVEMENT = 10; * @lends Touchable.prototype */ var TouchableMixin = { + /** + * Clear all timeouts on unmount + */ + componentWillUnmount: function() { + this.touchableDelayTimeout && clearTimeout(this.touchableDelayTimeout); + this.longPressDelayTimeout && clearTimeout(this.longPressDelayTimeout); + this.pressOutDelayTimeout && clearTimeout(this.pressOutDelayTimeout); + }, + /** * It's prefer that mixins determine state in this way, having the class * explicitly mix the state in the one and only `getInitialState` method.