Skip to content


Prevent hitslop crash on Android
Browse files Browse the repository at this point in the history
Currently to use the `hitSlop` property on Android you must define the object properties `left`, `top`, `right`, and `bottom` or it will crash. iOS allows omitting object properties from the hitSlop.

This change guards and allows the `hitSlop` object properties to be optional like iOS.

**Test plan (required)**

Run the [example]( and omit a hitslop property and check it does not crash.
Closes #10952

Differential Revision: D4182815

Pulled By: ericvicenti

fbshipit-source-id: 07d7aca67b5739d5d1939b257476c24dcb10cbb0
  • Loading branch information
AndrewJack authored and Facebook Github Bot committed Nov 15, 2016
1 parent 2cc57d0 commit c2a55ba
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -81,10 +81,10 @@ public void setHitSlop(final ReactViewGroup view, @Nullable ReadableMap hitSlop)
} else {
view.setHitSlopRect(new Rect(
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("left")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("top")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("right")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("bottom"))
hitSlop.hasKey("left") ? (int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("left")) : 0,
hitSlop.hasKey("top") ? (int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("top")) : 0,
hitSlop.hasKey("right") ? (int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("right")) : 0,
hitSlop.hasKey("bottom") ? (int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("bottom")) : 0
Expand Down

0 comments on commit c2a55ba

Please sign in to comment.