From 91d3a9539d28ef10275dc3e962f23da8c79cab19 Mon Sep 17 00:00:00 2001 From: Katy Chang Date: Tue, 26 Sep 2023 10:13:03 -0700 Subject: [PATCH] Change assertion to avoid crash in ReactScrollView.java (#39593) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39593 Looking into a crash leads by assertion error in this line, I talked to NickGerleman and we think there might be some case when ContentView is not rendered, so it would have 0 child. Changing the assertion to allow 0 child. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D49508540 fbshipit-source-id: 43c50814ead24332c1b24ff2dea50d564519034b --- .../java/com/facebook/react/views/scroll/ReactScrollView.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java index 16521c83f70..f66ed102018 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java @@ -1188,7 +1188,8 @@ public class ReactScrollView extends ScrollView int count = getChildCount(); Assertions.assertCondition( - count == 1, "React Native ScrollView always has exactly 1 child; a content View"); + count <= 1, + "React Native ScrollView should not have more than one child, it should have exactly 1 child; a content View"); if (count > 0) { for (int i = 0; i < count; i++) {