Clear timeouts on unmount in TouchableMixin

Summary: Fixes #1152
Closes https://github.com/facebook/react-native/pull/3176

Reviewed By: @​svcscm

Differential Revision: D2506385

Pulled By: @vjeux
This commit is contained in:
Dral 2015-10-03 11:45:28 -07:00 committed by facebook-github-bot-8
parent ac069aaf12
commit a9b8ca027c
1 changed files with 9 additions and 0 deletions

View File

@ -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.