-
-
Notifications
You must be signed in to change notification settings - Fork 982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TouchableOpacity is working in Android? #578
Comments
Hi @akiradeveloper I bumped version of React Native in Example app to 0.59.5 and TouchableOpacity on android records onPress events. You can check this out by yourself on this branch up until it gets merged to master 😊 https://github.com/kmagiera/react-native-gesture-handler/tree/upgrade-react-native |
Hello, I have the same issue right now with I have changed the import to use the touchables from the |
I have the same problem.. but in react native version 0.60.x TouchableOpacity of react-native library seems to work well. |
To not make mistake described by @PierreCapo again, added
|
Not able to get |
This is what I do, which is really ugly: /src/core/touchable/index.ios.ts // eslint-disable-next-line no-restricted-imports
export {
TouchableOpacity,
TouchableNativeFeedback,
TouchableHighlight,
TouchableWithoutFeedback,
FlatList,
ScrollView,
} from 'react-native-gesture-handler'; /src/core/touchable/index.ts // eslint-disable-next-line no-restricted-imports
export {
TouchableOpacity,
TouchableNativeFeedback,
TouchableHighlight,
TouchableWithoutFeedback,
FlatList,
ScrollView,
} from 'react-native'; eslint config: module.exports = {
extends: ['./eslint-config/native'],
rules: {
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'react-native-gesture-handler',
importNames: [
'TouchableOpacity',
'TouchableNativeFeedback',
'TouchableHighlight',
'TouchableWithoutFeedback',
'FlatList',
'ScrollView',
],
message: "Please import it from '/src/core/touchables' instead.",
},
{
name: 'react-native',
importNames: [
'TouchableOpacity',
'TouchableNativeFeedback',
'TouchableHighlight',
'TouchableWithoutFeedback',
'FlatList',
'ScrollView',
],
message: "Please import it from '/src/core/touchables' instead.",
},
],
},
],
},
}; |
What if I want to use TouchableNativeFeedback from |
this helped me: #699 |
@noway did you find any solution? i looked at the link you provided but unfortunately, my project is an expo manged one. So if you got any other solution please let me know. |
expo doesn't provide as much flexility as standard react native installation for issues exactly like this, so i'd recommend not to use it. |
I moved the child component to be a sibling of the touchable component and then gave it absolute positioning such that it draws over the child. It's a stupid hack but suits my use case. <View>
<TextInput
//editable={false}
/>
<TouchableOpacity
style={{position: 'absolute', left:0, top:0 ,width:'100%', height: '100%'}}
onPress={()=>{setIsModalVisible(true)}}>
</TouchableOpacity>
</View> |
I get back... Instead For some reason, The first one works as well on IOS but not on Android |
for someone has to use touchables from react-native-gesture-handler for iOS:
|
I wasn't able to repro that, TouchableOpacity is kinda working on android (doesn't have opacity though). Used code from the master branch (1d23e20). Could you guys please share some small reproduction example with RNGH version, so I can test and fix that? Example code used in GIF: import React from 'react';
import { SafeAreaView, Text, Platform } from 'react-native';
import { TouchableOpacity } from 'react-native-gesture-handler';
export default () => {
return (
<SafeAreaView style={styles.container}>
<TouchableOpacity
style={[styles.rectangle]}
onPress={() => console.log('Touch', Platform.OS)}>
<Text>Press me!</Text>
</TouchableOpacity>
</SafeAreaView>
);
};
const styles = {
container: { flex: 1, justifyContent: 'center', alignItems: 'center' },
rectangle: {
backgroundColor: 'pink',
width: 100,
height: 100,
alignItems: 'center',
justifyContent: 'center',
},
}; |
@jakub-gonet Seems like it does not work inside a Modal Please take a look at this snack https://snack.expo.io/@dattannguyen/touchableopacity-does-not-work-on-android |
@tandat2209, this may be related to #139. |
I confirm I used It is not on Modal either. In my case, I found it on storybook (image below). ( |
@bluenex, could you provide some small example of code? |
Here it is: import { TouchableOpacity } from 'react-native-gesture-handler';
import styled from styled-components;
const ButtonContainer = styled(TouchableOpacity)`...`;
const StyledView = styled.View`...`;
const Button = ({ children, ...buttonProps }) => (
<ButtonContainer {...buttonProps}>
<StyledView>
<Text>
{ children }
</Text>
</StyledView>
<ButtonContainer>
); So this is my custom button component which is styled using More information, I use UpdateSo I end up trying to add to |
It's not working in React native 0.62.2, 0.63.x and react-native-gesture-handler "^1.8.0" too. In fact in most versions of RN the problem is there. The onPress does not work at all. One must import it from "react-native" always for android |
Confirmed as well on the last version of the expo SDK
|
If you want to use import { TouchableOpacity } from 'react-native-gesture-handler';
...
<TouchableOpacity
onPress={() => {}}
containerStyle={{
position: 'absolute',
top: 0,
left: 0
}}
>
<Text>Press</Text>
</TouchableOpacity> |
I submitted PR fixing opacity effect but I wasn't able to repro this issue. If you still experience it, make sure you set up RNGH correctly and provide a working repro example. |
I am using RN 0.59.5 with this library and it seems that TouchableOpacity doesn't handle onPress hook in Android whereas it does in iOS. Is this a known issue?
The text was updated successfully, but these errors were encountered: