React Native: TouchableOpacity onPress problems inside a ScrollView
Set keyboardShouldPersistTaps={true}
on your ScrollView
.
Duplicate answer here: https://stackoverflow.com/a/34290788/29493
UPDATE: As Hossein writes in his answer, true|false
has been deprecated in newer versions in favor of always|never|handled
.
Set keyboardShouldPersistTaps='always'
to your ScrollView
props.
React Native Documentation:
'never' (the default), tapping outside of the focused text input when the keyboard is up dismisses the keyboard. When this happens, children won't receive the tap.
'always', the keyboard will not dismiss automatically, and the scroll view will not catch taps, but children of the scroll view can catch taps.
'handled', the keyboard will not dismiss automatically when the tap was handled by a children, (or captured by an ancestor).
false, deprecated, use 'never' instead.
true, deprecated, use 'always' instead.