Search code examples
reactjsreact-native

React Native: Cannot scroll <ScrollView> when touching anything that does not have `onPress` function


In short: Is ScrollView supposed to scroll only when pressing component that has onPress function or is something preventing it working as expected?

I noticed ScrollView works when touching on Buttons or other components with onPress function. But when trying to scroll it touching on for example <Text> component nothing happens. I noticed this by then adding onPress to <Text> component (as it has this functionality) and then scrolling works perfectly. Same could be applied to <View> components by changing them to <TouchableWithoutFeedback> with empty onPress: onPress={() => { }}.
But this should not be the case and it increases the workload.

There are tons of question regarding why React Native ScrollView is not working. I tried to found out if this question is answered already but did not come across.

"expo": "^43.0.1",
"react-native": "0.64.2

Solution

  • It seems that in ScrollView there needs to be main child component that has onPress functionality so that it can recognizes touch event.