Fix incorrect cast in RemoveDeleteTree (#43018)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43018

Assuming that if View is a ViewGroup, its ViewManager is a ViewGroupManager is incorrect. Custom ViewManagers may use ViewGroups internally to represent complex views exposed to JS.

Type-check the ViewManager instead to avoid the crash seen in T178300877

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53586565

fbshipit-source-id: 49408098cebc7f76d8be0e585187ba9b6ca52049
This commit is contained in:
Pieter De Baets
2024-02-15 05:39:23 -08:00
committed by Facebook GitHub Bot
parent 5a5c9eb96c
commit 53e3f364cf
@@ -1432,8 +1432,9 @@ public class SurfaceMountingManager {
ViewState thisViewState = getNullableViewState(reactTag);
if (thisViewState != null) {
View thisView = thisViewState.mView;
if (thisView instanceof ViewGroup) {
IViewGroupManager viewManager = getViewGroupManager(thisViewState);
ViewManager thisViewManager = thisViewState.mViewManager;
if (thisViewManager instanceof IViewGroupManager) {
IViewGroupManager viewManager = (IViewGroupManager) thisViewManager;
// Children are managed by React Native if both of the following are true:
// 1) There are 1 or more children of this View, which must be a ViewGroup