getChildAtWithSubviewClippingEnabled should be @Nullable

Summary:
The RemoveDeleteTree operation assumes it can safely call getChildAt with indices that are out of bounds to find all the children. `getChildAtWithSubviewClippingEnabled` was unnecessarily stricter than `getChildAt` and would crash in such cases.

Changelog: [Android][Fixed] - Fix crash in `getChildAtWithSubviewClippingEnabled`

Reviewed By: NickGerleman

Differential Revision: D54380975

fbshipit-source-id: 17e93c685cd07b02dc20efa2fae89090d6e38457
This commit is contained in:
Pieter De Baets
2024-03-01 03:59:08 -08:00
committed by Facebook GitHub Bot
parent 4d2262b8d2
commit d6a44e632a
@@ -637,8 +637,11 @@ public class ReactViewGroup extends ViewGroup
return mAllChildrenCount;
}
/*package*/ View getChildAtWithSubviewClippingEnabled(int index) {
return Assertions.assertNotNull(mAllChildren)[index];
/*package*/ @Nullable
View getChildAtWithSubviewClippingEnabled(int index) {
return index >= 0 && index < mAllChildrenCount
? Assertions.assertNotNull(mAllChildren)[index]
: null;
}
/*package*/ void addViewWithSubviewClippingEnabled(View child, int index) {