Skip to content

Commit b2343bc

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add assert for recycled views with parent
Summary: 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] Differential Revision: D70922503
1 parent 34ae9fa commit b2343bc

File tree

1 file changed

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

1 file changed

+4
-0
lines changed

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

Lines changed: 4 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,9 @@ 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+
"A recycled views should not be attached to a parent");
260264
recyclableViews.push(recyclableView);
261265
}
262266
}

0 commit comments

Comments
 (0)