Skip to content

Commit

Permalink
Add missing bind methods for gesture responder.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AndrewSouthpaw committed Oct 12, 2020
1 parent c671f00 commit 32fc04e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libraries/ViewTransformer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ export default class ViewTransformer extends React.Component {
onStartShouldSetResponder: (evt, gestureState) => true,
onMoveShouldSetResponderCapture: (evt, gestureState) => true,
// onMoveShouldSetResponder: this.handleMove,
onResponderMove: this.onResponderMove,
onResponderGrant: this.onResponderGrant,
onResponderRelease: this.onResponderRelease,
onResponderTerminate: this.onResponderRelease,
onResponderMove: this.onResponderMove.bind(this),
onResponderGrant: this.onResponderGrant.bind(this),
onResponderRelease: this.onResponderRelease.bind(this),
onResponderTerminate: this.onResponderRelease.bind(this),
onResponderTerminationRequest: (evt, gestureState) => false, // Do not allow parent view to intercept gesture
onResponderSingleTapConfirmed: (evt, gestureState) => {
this.props.onSingleTapConfirmed && this.props.onSingleTapConfirmed();
Expand Down

0 comments on commit 32fc04e

Please sign in to comment.