TouchableOpacity from React Native Gesture Handler doesn't work inside Modal
See original GitHub issueBug
Using react-native-gesture-handler’s TouchableOpacity inside BottomSheetModal doesn’t work. However, react-native’s Button inside BottomSheetModal does work.
Environment info
Library | Version |
---|---|
@gorhom/bottom-sheet | ^2.0.2 |
expo | ~40.0.0 |
react-native | https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz |
react-native-reanimated | 2.0.0-rc.0 |
react-native-gesture-handler | ~1.8.0 |
Steps To Reproduce
- expo init (basic config)
- yarn add @gorhom/bottom-sheet react-native-reanimated@2.0.0-rc.0 react-native-gesture-handler
- Replace App.js with the code below.
Describe what you expected to happen:
- Touchable Opacity inside the modal should register presses
Reproducible sample code
import {
BottomSheetModal,
BottomSheetModalProvider
} from '@gorhom/bottom-sheet';
import React, { useCallback, useRef, useState } from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';
import { TouchableOpacity } from "react-native-gesture-handler";
const App = () => {
const [count, setCount] = useState(1)
const bottomSheetModalRef = useRef(null);
const handlePresentModalPress = useCallback(() => {
bottomSheetModalRef.current?.present();
}, []);
return (
<BottomSheetModalProvider>
<View style={styles.container}>
<Button
onPress={handlePresentModalPress}
title="Present Modal"
color="black"
/>
<BottomSheetModal
ref={bottomSheetModalRef}
snapPoints={["50%"]}
>
<View style={styles.contentContainer}>
<TouchableOpacity onPress={() => setCount(p => p + 1)}><Text style={{color: "blue", fontSize: 18}}>Increase count with Touchable Opacity</Text></TouchableOpacity>
<Button title="increase count with RN Button" onPress={() => setCount(p => p + 1)}/>
<Text>{count}</Text>
</View>
</BottomSheetModal>
</View>
</BottomSheetModalProvider>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 24,
justifyContent: 'center',
backgroundColor: 'grey',
},
contentContainer: {
flex: 1,
justifyContent: "center",
alignItems: 'center',
},
});
export default App;
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
TouchableOpacity and button not working in react native Modal?
My problem was that I imported the TouchableOpacity from the react-native-gesture-handler package, rather then the default react-native ...
Read more >Troubleshooting | React Native Bottom Sheet - GitHub Pages
Pressables / Touchables are not working on Android. Due to wrapping the content and handle with TapGestureHandler & PanGestureHandler , any gesture interaction ......
Read more >react-native-modalize - npm
In a future version of react-native , the Modal component will be moved out from the core. Besides, react-native-gesture-handler for Android ...
Read more >Introduction | React Native Gesture Handler - Software Mansion
The ability to define relations between gesture handlers, e.g. when you have a pan handler in ScrollView you can make that ScrollView wait...
Read more >Accessibility - React Native
Create mobile apps accessible to assistive technology with React Native's suite of APIs designed to work with Android and iOS.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://gorhom.github.io/react-native-bottom-sheet/troubleshooting#pressables--touchables-are-not-working-on-android
@xotahal this been suggested with a pr, but it breaks the sheet functionality https://github.com/gorhom/react-native-bottom-sheet/pull/60#issuecomment-797089004