Fix NaN value comparison for Text component (#51421)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51421

See title

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D74915629

fbshipit-source-id: 0c24426c5e04ab3fc6ee85a4ca53e6095f0d3fce
This commit is contained in:
Nick Lefever authored and Facebook GitHub Bot committed 2025-05-19 03:12:48 -07:00
1 parent f278c94a12
commit 995129c757
1 file changed
+17 -9
@@ -12,6 +12,7 @@
#include <react/renderer/core/graphicsConversions.h>
#include <react/renderer/core/propsConversions.h>
#include <react/renderer/debug/DebugStringConvertibleItem.h>
#include <react/utils/FloatComparison.h>
namespace facebook::react {
@@ -377,12 +378,14 @@ void BaseTextProps::appendTextAttributesProps(
result["fontFamily"] = textAttributes.fontFamily;
}
if (textAttributes.fontSize != oldProps->textAttributes.fontSize) {
if (!floatEquality(
textAttributes.fontSize, oldProps->textAttributes.fontSize)) {
result["fontSize"] = textAttributes.fontSize;
}
if (textAttributes.fontSizeMultiplier !=
oldProps->textAttributes.fontSizeMultiplier) {
if (!floatEquality(
textAttributes.fontSizeMultiplier,
oldProps->textAttributes.fontSizeMultiplier)) {
result["fontSizeMultiplier"] = textAttributes.fontSizeMultiplier;
}
@@ -411,8 +414,9 @@ void BaseTextProps::appendTextAttributesProps(
: folly::dynamic(nullptr);
}
if (textAttributes.maxFontSizeMultiplier !=
oldProps->textAttributes.maxFontSizeMultiplier) {
if (!floatEquality(
textAttributes.maxFontSizeMultiplier,
oldProps->textAttributes.maxFontSizeMultiplier)) {
result["maxFontSizeMultiplier"] = textAttributes.maxFontSizeMultiplier;
}
@@ -423,7 +427,9 @@ void BaseTextProps::appendTextAttributesProps(
: nullptr;
}
if (textAttributes.letterSpacing != oldProps->textAttributes.letterSpacing) {
if (!floatEquality(
textAttributes.letterSpacing,
oldProps->textAttributes.letterSpacing)) {
result["letterSpacing"] = textAttributes.letterSpacing;
}
@@ -440,7 +446,8 @@ void BaseTextProps::appendTextAttributesProps(
: nullptr;
}
if (textAttributes.lineHeight != oldProps->textAttributes.lineHeight) {
if (!floatEquality(
textAttributes.lineHeight, oldProps->textAttributes.lineHeight)) {
result["lineHeight"] = textAttributes.lineHeight;
}
@@ -500,8 +507,9 @@ void BaseTextProps::appendTextAttributesProps(
: nullptr;
}
if (textAttributes.textShadowRadius !=
oldProps->textAttributes.textShadowRadius) {
if (!floatEquality(
textAttributes.textShadowRadius,
oldProps->textAttributes.textShadowRadius)) {
result["textShadowRadius"] = textAttributes.textShadowRadius;
}