software-mansion / react-native-svg

SVG library for React Native, React Native Web, and plain React web projects.
MIT License
7.42k stars 1.12k forks source link

[Bug] the hitSlop value should use float on android like on ios #2326

Closed GrinZero closed 1 week ago

GrinZero commented 2 months ago

Description

On IOS, the hitSlop attribute of Svg supports the direct use of hitSlope={4}, but it can cause crashes on Android. The native view is also compatible with this writing style, so I think we should add compatibility in this area, otherwise it may lead to hidden cross end compatibility issues.

Steps to reproduce

On any android deviced use the code like <Svg hitSlop={4}/>

  1. open the snack link, the device can not been open with hitSlop={40}
  2. change the code to hitSlop={{top:40,bottom:40,left:40,right:40}}, the device can run success.

Snack or a link to a repository

https://snack.expo.dev/@bugyaluwang/react-native-svg-hit

SVG version

15.3.0

React Native version

0.74.2

Platforms

Android

JavaScript runtime

Hermes

Workflow

Expo Go

Architecture

Fabric (New Architecture)

Build type

Debug app & dev bundle

Device

Real device

Device model

MEIZU 20 Pro

Acknowledgements

Yes

GrinZero commented 2 months ago

this PR is ready for this issues: https://github.com/software-mansion/react-native-svg/pull/2323

jakex7 commented 1 week ago

Hi @GrinZero, I've made a PR solving this issue https://github.com/software-mansion/react-native-svg/pull/2407 with iOS and Android support. Thank you!