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
This commit is contained in:
Thomas Nardone
2024-08-15 08:44:32 -07:00
committed by Facebook GitHub Bot
parent 26aff664c0
commit 49fa92e016
@@ -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);