diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphLayoutManager.cpp b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphLayoutManager.cpp index 623b17ab8131f8..7dbd216892eb31 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphLayoutManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphLayoutManager.cpp @@ -42,20 +42,22 @@ bool ParagraphLayoutManager::shoudMeasureString( AttributedString const &attributedString, ParagraphAttributes const ¶graphAttributes, LayoutConstraints layoutConstraints) const { - size_t newHash = folly::hash::hash_combine( - 0, - textAttributedStringHashLayoutWise(attributedString), - paragraphAttributes); + size_t newParagraphInputHash = + folly::hash::hash_combine(0, attributedString, paragraphAttributes); - if (newHash != paragraphInputHash_) { + if (newParagraphInputHash != paragraphInputHash_) { // AttributedString or ParagraphAttributes have changed. // Must create new host text storage and trigger measure. hostTextStorage_ = textLayoutManager_->getHostTextStorage( attributedString, paragraphAttributes, layoutConstraints); - paragraphInputHash_ = newHash; + paragraphInputHash_ = newParagraphInputHash; + return true; // Must measure again. } + // Detect the case when available width for Paragraph meaningfully changes. + // This is to prevent unnecessary re-creation of NSTextStorage on iOS. + // On Android, this is no-op. bool hasMaximumSizeChanged = layoutConstraints.maximumSize.width != lastAvailableWidth_; Float threshold = 0.01f; diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h index 0936994b5da60f..b44e8f416dc675 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h +++ b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphShadowNode.h @@ -9,7 +9,6 @@ #include #include -#include #include #include #include