Unable to add onPress event on SVG Path #2194
Replies: 1 comment
-
Hello @mshakirkhan, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I need help. In React Native CLI I am unable to add an onPress event on Path in my SVG, I am trying to simply Alert when I press the path, I am using the 14.1.0 version, and the React Native version is 0.72.4. Here is my code
import Svg, { Path, G, Rect, Defs } from "react-native-svg";
import { View, TouchableOpacity, TouchableHighlight, StyleSheet, Alert } from "react-native";
const SvgComponent = () => {
const handlePress = () => {
Alert.alert('Path Pressed!', 'You have pressed the SVG path.');
}
return (
<View style={{ backgroundColor: 'grey', margin: 0, padding: 0, width:'100%', height:400 }}>
<Svg style={{ margin: 0, padding: 0}} viewBox="0 0 2075 1991" width="100%" height="100%" fill="none">
)
}
const styles = StyleSheet.create({
});
export default SvgComponent
Beta Was this translation helpful? Give feedback.
All reactions