Search code examples
iosreact-nativetouchreact-native-flatlist

React Native FlatList consuming all touches (ToucableWithoutFeedback onPress not called)


I have a FlatList in my React Native app and I'm rendering regular cells. I've added Touchables and onPress events as usual inside the cells but my cells aren't receiving touch events. I'm currently on iOS and I've tried to intercept touch events (by overriding UIApplications touchesBegan:withEvent: method in Xcide) but for some reason the application isn't receiving touch events when tapped inside the FlatList (the method isn't called). Flat list scrolls fine (gesture recognizer works), but somehow the app (and none of the views) isn't receiving touch events. If I tap anywhere outside the bounds of the FlatList, touches are received and processed correctly.

How can I make touch events work normally? I'm on React Native 0.59.8.


Solution

  • It was a bug with React Native (even though the bug is closed due to inactivity, this is exactly what is happening with me too) at https://github.com/facebook/react-native/issues/23740. I've switched to TouchableOpacity with opacity set to 1 (to mimic the same visual behavior) and the problem went away. Even though this is not a real solution rather a workaround, the bug originates from React Native itself so I think going with the workaround is the best solution for now.