react-native-svg
react-native-svg copied to clipboard
Android onPress Problem
Hello friends. The function in the line of code below works fine on IOS, but not on Android. Why could it be?
<Path
onPress={() => changeCeiling(ceilingCount === 0 ? "#F7CB52" : ceilingCount === 1 ? "#EB4573" : "#00B8FE")} fill={ceiling}
id="Path_3647"
data-name="Path 3647"
d="M4398.123,8491.008c.222,7.107,0,15.558,0,15.558v39.352s17.227,4.751,33.4,4.82a119.782,119.782,0,0,0,31.286-4.546l-.116-40.973s-.016-7.205.706-14.211S4397.9,8483.9,4398.123,8491.008Z"
transform="translate(-4243.262 -8053.945)"
stroke="#707070"
stroke-width="1"
/>
What's your react-native-svg version? I tried with 12.x and 13.x, I have no problem with on press event on Android.
Hello @TomCorvus
I can give an expo on Android if you want.
"react-native-svg": "12.3.0"
My problem still persists.
hi @ugurcanalyuz Yes please, if you can provide an example.
Hello @TomCorvus https://snack.expo.dev/@atlteknoloji/rn-svg-android-problem
IOS is so good Working and Android hard working :)
Hello @TomCorvus, Have you had a chance to review?
@ugurcanalyuz I checked but I have no fix for now. onPress event on paths on left and right of your SVG is working on both platforms for me but not paths on center. If I log onPress event, it is the Svg onPress event which is triggered not path. Do you have same behavior? It's maybe the same problem as https://github.com/react-native-svg/react-native-svg/issues/1826 I'll edit this message if I find something.
Solution: use onPressIn instead of onPress.
I just encountered this issue, seems like it's related to the default touchableHandleResponderMove function and the scale of the svg, i would have loved to open a PR with a fix, but i still haven't been able to fix it.