From 9ea7957958c3f7acdaec6309117af61072986818 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 8 May 2018 18:50:19 -0700 Subject: [PATCH] Fabric: Do not crash in attempt to mount layout-only components Summary: We do not have a clear strategy how to deal with layout-only (view-less) components. Even if this particular solution is not so fancy, it prevents crashing during text rendering. Reviewed By: mdvacca Differential Revision: D7785885 fbshipit-source-id: f3ed8988aa2b41349fd1693c2a7f8c9368daee43 --- React/Fabric/Mounting/MountItems/RCTDeleteMountItem.mm | 5 +++++ React/Fabric/Mounting/MountItems/RCTInsertMountItem.mm | 4 ++++ React/Fabric/Mounting/MountItems/RCTRemoveMountItem.mm | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/React/Fabric/Mounting/MountItems/RCTDeleteMountItem.mm b/React/Fabric/Mounting/MountItems/RCTDeleteMountItem.mm index 99909f450..ed4a884e4 100644 --- a/React/Fabric/Mounting/MountItems/RCTDeleteMountItem.mm +++ b/React/Fabric/Mounting/MountItems/RCTDeleteMountItem.mm @@ -28,6 +28,11 @@ - (void)executeWithRegistry:(RCTComponentViewRegistry *)registry { UIView *componentView = [registry componentViewByTag:_tag]; + + if (componentView == nil) { + return; + } + [registry enqueueComponentViewWithName:_componentName tag:_tag componentView:componentView]; } diff --git a/React/Fabric/Mounting/MountItems/RCTInsertMountItem.mm b/React/Fabric/Mounting/MountItems/RCTInsertMountItem.mm index f714cb0a7..740718b96 100644 --- a/React/Fabric/Mounting/MountItems/RCTInsertMountItem.mm +++ b/React/Fabric/Mounting/MountItems/RCTInsertMountItem.mm @@ -33,6 +33,10 @@ UIView *childComponentView = [registry componentViewByTag:_childTag]; UIView *parentComponentView = [registry componentViewByTag:_parentTag]; + if (childComponentView == nil || parentComponentView == nil) { + return; + } + [parentComponentView mountChildComponentView:childComponentView index:_index]; } diff --git a/React/Fabric/Mounting/MountItems/RCTRemoveMountItem.mm b/React/Fabric/Mounting/MountItems/RCTRemoveMountItem.mm index d46b936dd..3279b9394 100644 --- a/React/Fabric/Mounting/MountItems/RCTRemoveMountItem.mm +++ b/React/Fabric/Mounting/MountItems/RCTRemoveMountItem.mm @@ -33,6 +33,10 @@ UIView *childComponentView = [registry componentViewByTag:_childTag]; UIView *parentComponentView = [registry componentViewByTag:_parentTag]; + if (childComponentView == nil || parentComponentView == nil) { + return; + } + [parentComponentView unmountChildComponentView:childComponentView index:_index]; }