diff --git a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index 190d3e9db5deff..a56e1d7ccd7f6c 100644 --- a/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -209,20 +209,25 @@ void YogaLayoutableShadowNode::appendChild( yogaNode_.setDirty(true); // All children of a non-leaf `YogaLayoutableShadowNode` must be a - // `YogaLayoutableShadowNode`s. - react_native_assert( - traitCast(childNode.get())); - - // Appending the Yoga node. - appendYogaChild(*childNode); - - ensureYogaChildrenLookFine(); - ensureYogaChildrenAlighment(); - - // Adopting the Yoga node. - adoptYogaChild(getChildren().size() - 1); - - ensureConsistency(); + // `YogaLayoutableShadowNode`s to be appended. This happens when invalid + // string/numeric child is passed which is not YogaLayoutableShadowNode + // (e.g. RCTRawText). This used to throw an error, but we are ignoring it + // because we want core library components to be fault-tolerant and degrade + // gracefully. A soft error will be emitted from JavaScript. + if (traitCast(childNode.get())) { + // Appending the Yoga node. + appendYogaChild(*childNode); + + ensureYogaChildrenLookFine(); + ensureYogaChildrenAlighment(); + + // Adopting the Yoga node. + adoptYogaChild(getChildren().size() - 1); + + ensureConsistency(); + } else { + LOG(ERROR) << "Text strings must be rendered within a component."; + } } bool YogaLayoutableShadowNode::doesOwn(