From d63762194d7c9ba8ebf6774ef25948cb87a3e694 Mon Sep 17 00:00:00 2001 From: Eaden <_@eaden.net> Date: Tue, 15 Mar 2016 12:16:52 -0700 Subject: [PATCH] Fix bug #5604 - Unrecognised signal for touchable no longer on the screen Summary:Fixes bug https://github.com/facebook/react-native/issues/5604 ("Redscreen error when TouchRelease triggered on a component no longer in the tree") ( maybe not ideally ) This issue is triggered by the following: A Touch event on a component ( Keep Pressing ) A state/props update removes the component from the tree and render is performed A Touch Release event. ( When you release the press on the component no longer there ) This fix adds an early return to the signal handling code if a RESPONDER_RELEASE signal happens when the responder has disappeared Closes https://github.com/facebook/react-native/pull/5637 Differential Revision: D3053729 Pulled By: sahrens fb-gh-sync-id: 21a2a303d8921654607eaab824ef28fc16df9500 shipit-source-id: 21a2a303d8921654607eaab824ef28fc16df9500 --- Libraries/Components/Touchable/Touchable.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index 4f5000c5c..55be8e0dc 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -599,18 +599,22 @@ var TouchableMixin = { * @sideeffects */ _receiveSignal: function(signal, e) { + var responderID = this.state.touchable.responderID; var curState = this.state.touchable.touchState; var nextState = Transitions[curState] && Transitions[curState][signal]; + if (!responderID && signal === Signals.RESPONDER_RELEASE) { + return; + } if (!nextState) { throw new Error( 'Unrecognized signal `' + signal + '` or state `' + curState + - '` for Touchable responder `' + this.state.touchable.responderID + '`' + '` for Touchable responder `' + responderID + '`' ); } if (nextState === States.ERROR) { throw new Error( 'Touchable cannot transition from `' + curState + '` to `' + signal + - '` for responder `' + this.state.touchable.responderID + '`' + '` for responder `' + responderID + '`' ); } if (curState !== nextState) {