From ec72af403ca6cc64a6c7e99b00a6a6b5d56ff2db Mon Sep 17 00:00:00 2001 From: Peter Abbondanzo Date: Tue, 7 Jan 2025 15:13:34 -0800 Subject: [PATCH] Mark string props as nullable in scrollview managers (#48520) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48520 Both `ReactScrollViewHelper.parseSnapToAlignment` and `ReactScrollViewHelper.parseOverScrollMode` accept a nullable string. This is a precursor to migrating these files to Kotlin (since they're already marked as nullsafe). The prop itself is a nullable string so this should be reflected in the native types as well Changelog: [Internal] Reviewed By: tdn120 Differential Revision: D67911553 fbshipit-source-id: aabe55c2dc65a933b170d76b89f62f25493ab0ee --- .../views/scroll/ReactHorizontalScrollViewManager.java | 6 +++--- .../facebook/react/views/scroll/ReactScrollViewManager.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java index 0d6b0a583aeec3..9cd7a38c0cdc1e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollViewManager.java @@ -109,7 +109,7 @@ public void setSnapToInterval(ReactHorizontalScrollView view, float snapToInterv } @ReactProp(name = "snapToAlignment") - public void setSnapToAlignment(ReactHorizontalScrollView view, String alignment) { + public void setSnapToAlignment(ReactHorizontalScrollView view, @Nullable String alignment) { view.setSnapToAlignment(ReactScrollViewHelper.parseSnapToAlignment(alignment)); } @@ -166,7 +166,7 @@ public void setSendMomentumEvents(ReactHorizontalScrollView view, boolean sendMo * @param scrollPerfTag */ @ReactProp(name = "scrollPerfTag") - public void setScrollPerfTag(ReactHorizontalScrollView view, String scrollPerfTag) { + public void setScrollPerfTag(ReactHorizontalScrollView view, @Nullable String scrollPerfTag) { view.setScrollPerfTag(scrollPerfTag); } @@ -177,7 +177,7 @@ public void setPagingEnabled(ReactHorizontalScrollView view, boolean pagingEnabl /** Controls overScroll behaviour */ @ReactProp(name = "overScrollMode") - public void setOverScrollMode(ReactHorizontalScrollView view, String value) { + public void setOverScrollMode(ReactHorizontalScrollView view, @Nullable String value) { view.setOverScrollMode(ReactScrollViewHelper.parseOverScrollMode(value)); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java index e9d28efec0a296..b9260c5ca5a627 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.java @@ -123,7 +123,7 @@ public void setSnapToOffsets(ReactScrollView view, @Nullable ReadableArray snapT } @ReactProp(name = "snapToAlignment") - public void setSnapToAlignment(ReactScrollView view, String alignment) { + public void setSnapToAlignment(ReactScrollView view, @Nullable String alignment) { view.setSnapToAlignment(ReactScrollViewHelper.parseSnapToAlignment(alignment)); } @@ -186,7 +186,7 @@ public void setBottomFillColor(ReactScrollView view, int color) { /** Controls overScroll behaviour */ @ReactProp(name = "overScrollMode") - public void setOverScrollMode(ReactScrollView view, String value) { + public void setOverScrollMode(ReactScrollView view, @Nullable String value) { view.setOverScrollMode(ReactScrollViewHelper.parseOverScrollMode(value)); }