mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add assert for recycled views with parent (#49937)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
54e8bd44bd
commit
1482dd9e99
+11
@@ -12,6 +12,7 @@ import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.BaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
@@ -257,6 +258,16 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
if (recyclableViews != null) {
|
||||
T recyclableView = prepareToRecycleView(themedReactContext, view);
|
||||
if (recyclableView != null) {
|
||||
Assertions.assertCondition(
|
||||
recyclableView.getParent() == null,
|
||||
"Recycled view ["
|
||||
+ view.getId()
|
||||
+ "] should not be attached to a parent. View: "
|
||||
+ view
|
||||
+ " Parent: "
|
||||
+ recyclableView.getParent()
|
||||
+ " ThemedReactContext: "
|
||||
+ themedReactContext);
|
||||
recyclableViews.push(recyclableView);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user