mirror of
https://github.com/status-im/react-native.git
synced 2025-02-05 06:04:15 +00:00
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
This commit is contained in:
parent
0a35529d53
commit
d63762194d
@ -599,18 +599,22 @@ var TouchableMixin = {
|
|||||||
* @sideeffects
|
* @sideeffects
|
||||||
*/
|
*/
|
||||||
_receiveSignal: function(signal, e) {
|
_receiveSignal: function(signal, e) {
|
||||||
|
var responderID = this.state.touchable.responderID;
|
||||||
var curState = this.state.touchable.touchState;
|
var curState = this.state.touchable.touchState;
|
||||||
var nextState = Transitions[curState] && Transitions[curState][signal];
|
var nextState = Transitions[curState] && Transitions[curState][signal];
|
||||||
|
if (!responderID && signal === Signals.RESPONDER_RELEASE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!nextState) {
|
if (!nextState) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Unrecognized signal `' + signal + '` or state `' + curState +
|
'Unrecognized signal `' + signal + '` or state `' + curState +
|
||||||
'` for Touchable responder `' + this.state.touchable.responderID + '`'
|
'` for Touchable responder `' + responderID + '`'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (nextState === States.ERROR) {
|
if (nextState === States.ERROR) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Touchable cannot transition from `' + curState + '` to `' + signal +
|
'Touchable cannot transition from `' + curState + '` to `' + signal +
|
||||||
'` for responder `' + this.state.touchable.responderID + '`'
|
'` for responder `' + responderID + '`'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (curState !== nextState) {
|
if (curState !== nextState) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user