diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java index ecb72fff78746f..7f11c77abf3a22 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java @@ -304,8 +304,8 @@ public void setFadingEdgeLength(ReactHorizontalScrollView view, int value) { @ReactProp(name = "contentOffset") public void setContentOffset(ReactHorizontalScrollView view, ReadableMap value) { if (value != null) { - double x = value.getDouble("x"); - double y = value.getDouble("y"); + double x = value.hasKey("x") ? value.getDouble("x") : 0; + double y = value.hasKey("y") ? value.getDouble("y") : 0; view.reactScrollTo((int) PixelUtil.toPixelFromDIP(x), (int) PixelUtil.toPixelFromDIP(y)); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java index ed7cd05778836e..adf04118c3f437 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java @@ -308,8 +308,8 @@ public void setFadingEdgeLength(ReactScrollView view, int value) { @ReactProp(name = "contentOffset") public void setContentOffset(ReactScrollView view, ReadableMap value) { if (value != null) { - double x = value.getDouble("x"); - double y = value.getDouble("y"); + double x = value.hasKey("x") ? value.getDouble("x") : 0; + double y = value.hasKey("y") ? value.getDouble("y") : 0; view.reactScrollTo((int) PixelUtil.toPixelFromDIP(x), (int) PixelUtil.toPixelFromDIP(y)); } }