Skip to content

Conversation

@jaulz
Copy link
Collaborator

@jaulz jaulz commented Jun 30, 2020

Summary

There are situations when the touches array is empty and thus it causes errors.
image

As I noticed it especially with react-native-web@^0.13.0 I checked their code and they have a similar check:
https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/hooks/usePressEvents/PressResponder.js#L548-L557

Test plan

Unfortunately, I cannot provide an example that reproduces the issue but I noticed it once in a while with react-native-web@^0.13.0.

@github-actions
Copy link

The mobile version of example app from this branch is ready! You can see it here

.

@Trancever Trancever requested a review from satya164 June 30, 2020 09:16
: e.pageY;
const { changedTouches, touches } = e.nativeEvent;
const touch = touches?.[0] || changedTouches?.[0];
const startX = touch.pageX || e.pageX;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause bugs if touch.pageX is 0. Can we handle this case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good catch 😊 I just fixed it.

@callstack-bot
Copy link

Hey @jaulz, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

Copy link
Contributor

@Trancever Trancever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jaulz !

@Trancever Trancever merged commit 704e66b into master Jun 30, 2020
@jaulz jaulz deleted the jaulz/fix-catch-empty-touches branch June 30, 2020 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants