Skip to content

Commit 32fc04e

Browse files
Add missing bind methods for gesture responder.
Somehow the context is getting dropped *some of the time*, so that `this` becomes undefined inside `onResponderGrant`. Binding the methods to the instance fixes the issue. It's unclear how it's only happening some of the time -- usually binding issues will become immediate apparent with React -- so my best guess is there's some detail inside the React Native system where the context can be dropped.
1 parent c671f00 commit 32fc04e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libraries/ViewTransformer/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ export default class ViewTransformer extends React.Component {
100100
onStartShouldSetResponder: (evt, gestureState) => true,
101101
onMoveShouldSetResponderCapture: (evt, gestureState) => true,
102102
// onMoveShouldSetResponder: this.handleMove,
103-
onResponderMove: this.onResponderMove,
104-
onResponderGrant: this.onResponderGrant,
105-
onResponderRelease: this.onResponderRelease,
106-
onResponderTerminate: this.onResponderRelease,
103+
onResponderMove: this.onResponderMove.bind(this),
104+
onResponderGrant: this.onResponderGrant.bind(this),
105+
onResponderRelease: this.onResponderRelease.bind(this),
106+
onResponderTerminate: this.onResponderRelease.bind(this),
107107
onResponderTerminationRequest: (evt, gestureState) => false, // Do not allow parent view to intercept gesture
108108
onResponderSingleTapConfirmed: (evt, gestureState) => {
109109
this.props.onSingleTapConfirmed && this.props.onSingleTapConfirmed();

0 commit comments

Comments
 (0)