From 49fa92e0169e8d41fe7716454634752e76442de5 Mon Sep 17 00:00:00 2001 From: Thomas Nardone Date: Thu, 15 Aug 2024 08:44:32 -0700 Subject: [PATCH] ReactViewGroup - use safer removeViewInLayout (#45980) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45980 Use a safe remove method that won't crash on IndexOutOfBounds. Changelog: [Internal] Reviewed By: javache Differential Revision: D61132496 fbshipit-source-id: edd887611c47f236b495986fc29e2d0b9ce56b8e --- .../main/java/com/facebook/react/views/view/ReactViewGroup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java index 77011921d67..863dd958a6b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java @@ -466,7 +466,7 @@ public class ReactViewGroup extends ViewGroup if (!intersects && child.getParent() != null && !isAnimating) { // We can try saving on invalidate call here as the view that we remove is out of visible area // therefore invalidation is not necessary. - removeViewsInLayout(idx - clippedSoFar, 1); + removeViewInLayout(child); needUpdateClippingRecursive = true; } else if (intersects && child.getParent() == null) { addViewInLayout(child, idx - clippedSoFar, sDefaultLayoutParam, true);