onPress does not work
See original GitHub issueThis is the demo code in react-native-svg-example, it works when I run the demo. But when I copy this code to my own project, it draw the svg, but never respond when I press on the svg.
`class GroupExample extends Component { static title = ‘Bind touch events callback on Group element with viewBox’;
render () {
return <Svg
height="120"
width="120"
viewBox="0 0 240 240"
>
<G onPressIn={() => alert('Pressed on G')}>
<G scale="1.4">
<G>
<Circle cx="80" cy="80" r="30" fill="green" x="20" scale="1.2"/>
<Rect x="20" y="20" width="40" height="40" fill="yellow" />
</G>
</G>
</G>
</Svg>;
}
}`
PS: If I change the code
<G onPressIn={() => alert('Pressed on G')}>
to
<G onPressIn={alert('Pressed on G')}>
it pop up the alert window once when I run the project, but do not respond the press event either.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
React Native onpress not working - Stack Overflow
I'm using react-native 0.66 version and it's working fine. import React, { useState } from 'react'; import { StyleSheet,Text,View } from "react-native"; const ......
Read more >RectButton onPress does not work · Issue #699 - GitHub
Hi, RectButton's onPress doesn't work. I'm using React Native 0.60.4 inside of a Styled Component: export const Hour = styled(RectButton)` ...
Read more >Handling Touches - React Native
The "Touchable" components provide the capability to capture tapping gestures, and can display feedback when a gesture is recognized. These ...
Read more >React native TouchableOpacity onPress not working on Android
Android : React native TouchableOpacity onPress not working on Android [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] ...
Read more >React Native: View onPress does not work - iTecNote
I'm facing a weird problem. In my react native app, if I set onPress event to View it is not triggered but if...
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
Same issue on October 2019! Any hero to the rescue?
NinjaXY try putting your onPress handler on the circle or rect instead as in: https://github.com/magicismight/react-native-svg-example/pull/7/commits/e5616d29fc707da68ea895d02a633bf78a4dd495#diff-72145b9bb2d9b248b3cc6379238dd173R173
Or something more like this: https://snack.expo.io/HJuqTiJHM
Make sure you have stroke or fill color where you are pressing. Create e.g. a Rect or Circle with the color o the background for the entire area you want to be touch sensitive.