diff --git a/ReactCommon/fabric/components/text/basetext/BaseTextShadowNode.cpp b/ReactCommon/fabric/components/text/basetext/BaseTextShadowNode.cpp index 7c7036fbc4a..aaa8e83e2da 100644 --- a/ReactCommon/fabric/components/text/basetext/BaseTextShadowNode.cpp +++ b/ReactCommon/fabric/components/text/basetext/BaseTextShadowNode.cpp @@ -29,7 +29,15 @@ AttributedString BaseTextShadowNode::getAttributedString( auto fragment = AttributedString::Fragment{}; fragment.string = rawTextShadowNode->getProps()->text; fragment.textAttributes = textAttributes; - fragment.parentShadowNode = parentNode; + + // Storing a retaining pointer to `ParagraphShadowNode` inside + // `attributedString` causes a retain cycle (besides that fact that we + // don't need it at all). Storing a `ShadowView` instance instead of + // `ShadowNode` should properly fix this problem. + fragment.parentShadowNode = + std::dynamic_pointer_cast(parentNode) + ? parentNode + : nullptr; attributedString.appendFragment(fragment); continue; }