Listen to any touch gesture in the React Native component

Given the simple React Native presentation structure, which is as follows:

  • TouchableWithoutFeedback (with onPress handler)
    • View
    • TouchableHighlight (with onPress handler)
    • View
      • View
        • Text
    • TouchableHighlight (with onPress handler)

I want to be able to detect all the cranes at the top level (TouchableWithoutFeedback), even the cranes that go to one of the TouchableHighlight onPress handlers. It seems that if the user clicks on one of the TouchableHighlights, not a single event extends to TouchableWithoutFeedback.

In this simplified view, it would be simple enough for TouchableHighlights to take a handler that talks to the top-level component, but my actual view is too complex, and I will need to do every pass-through access to the re-access information.

Based on this issue from RN Github ( https://github.com/facebook/react-native/issues/6796 ), it seems that this may not be the functionality that is supported, but I just wanted to confirm.

FWIW, I am developing for Android only at the moment.

+4
source share

Source: https://habr.com/ru/post/1667928/


All Articles