mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add invariant to SurfaceMountingManager: Views must not have parents when they are inserted
Summary: We have no evidence of this happening on Android, but we are hitting a similar invariant on iOS. Adding this to Android for debugging purposes. For now it's a SoftException to catch in debug and capture information; if we don't hit this prod at all, we'll elevate to a hard crash. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26281585 fbshipit-source-id: 8ea9cf3ac555b13bf311f24c81bbbbc2845521d5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e723294630
commit
e0f1101e7e
+17
@@ -260,6 +260,23 @@ public class SurfaceMountingManager {
|
||||
logViewHierarchy(parentView, false);
|
||||
}
|
||||
|
||||
ViewParent viewParent = view.getParent();
|
||||
if (viewParent != null) {
|
||||
int actualParentId =
|
||||
viewParent instanceof ViewGroup ? ((ViewGroup) viewParent).getId() : View.NO_ID;
|
||||
ReactSoftException.logSoftException(
|
||||
TAG,
|
||||
new IllegalStateException(
|
||||
"addViewAt: cannot insert view ["
|
||||
+ tag
|
||||
+ "] into parent ["
|
||||
+ parentTag
|
||||
+ "]: View already has a parent: ["
|
||||
+ actualParentId
|
||||
+ "] "
|
||||
+ viewParent.getClass().getSimpleName()));
|
||||
}
|
||||
|
||||
try {
|
||||
getViewGroupManager(parentViewState).addView(parentView, view, index);
|
||||
} catch (IllegalStateException e) {
|
||||
|
||||
Reference in New Issue
Block a user