Skip to content

Commit 1482dd9

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add assert for recycled views with parent (facebook#49937)
Summary: Pull Request resolved: facebook#49937 Adding an assert for recycled views still attached to their parent, which would lead to an exception when the view would be added to a new parent. Changelog: [Internal] Reviewed By: javache Differential Revision: D70922503 fbshipit-source-id: 7d4daf427306203d603c31999ab138b3aee08e83
1 parent 54e8bd4 commit 1482dd9

File tree

1 file changed

+11
-0
lines changed
  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager

1 file changed

+11
-0
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import androidx.annotation.NonNull;
1313
import androidx.annotation.Nullable;
1414
import com.facebook.common.logging.FLog;
15+
import com.facebook.infer.annotation.Assertions;
1516
import com.facebook.react.bridge.BaseJavaModule;
1617
import com.facebook.react.bridge.ReactApplicationContext;
1718
import com.facebook.react.bridge.ReactContext;
@@ -257,6 +258,16 @@ public void onDropViewInstance(@NonNull T view) {
257258
if (recyclableViews != null) {
258259
T recyclableView = prepareToRecycleView(themedReactContext, view);
259260
if (recyclableView != null) {
261+
Assertions.assertCondition(
262+
recyclableView.getParent() == null,
263+
"Recycled view ["
264+
+ view.getId()
265+
+ "] should not be attached to a parent. View: "
266+
+ view
267+
+ " Parent: "
268+
+ recyclableView.getParent()
269+
+ " ThemedReactContext: "
270+
+ themedReactContext);
260271
recyclableViews.push(recyclableView);
261272
}
262273
}

0 commit comments

Comments
 (0)