Skip to content

Commit 3f30864

Browse files
Nick Lefeverfacebook-github-bot
Nick Lefever
authored andcommitted
Fix NaN value comparison for Text component (#51421)
Summary: See title Changelog: [Internal] Differential Revision: D74915629
1 parent 38d873d commit 3f30864

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

packages/react-native/ReactCommon/react/renderer/components/text/BaseTextProps.cpp

+17-9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <react/renderer/core/graphicsConversions.h>
1313
#include <react/renderer/core/propsConversions.h>
1414
#include <react/renderer/debug/DebugStringConvertibleItem.h>
15+
#include <react/utils/FloatComparison.h>
1516

1617
namespace facebook::react {
1718

@@ -377,12 +378,14 @@ void BaseTextProps::appendTextAttributesProps(
377378
result["fontFamily"] = textAttributes.fontFamily;
378379
}
379380

380-
if (textAttributes.fontSize != oldProps->textAttributes.fontSize) {
381+
if (!floatEquality(
382+
textAttributes.fontSize, oldProps->textAttributes.fontSize)) {
381383
result["fontSize"] = textAttributes.fontSize;
382384
}
383385

384-
if (textAttributes.fontSizeMultiplier !=
385-
oldProps->textAttributes.fontSizeMultiplier) {
386+
if (!floatEquality(
387+
textAttributes.fontSizeMultiplier,
388+
oldProps->textAttributes.fontSizeMultiplier)) {
386389
result["fontSizeMultiplier"] = textAttributes.fontSizeMultiplier;
387390
}
388391

@@ -411,8 +414,9 @@ void BaseTextProps::appendTextAttributesProps(
411414
: folly::dynamic(nullptr);
412415
}
413416

414-
if (textAttributes.maxFontSizeMultiplier !=
415-
oldProps->textAttributes.maxFontSizeMultiplier) {
417+
if (!floatEquality(
418+
textAttributes.maxFontSizeMultiplier,
419+
oldProps->textAttributes.maxFontSizeMultiplier)) {
416420
result["maxFontSizeMultiplier"] = textAttributes.maxFontSizeMultiplier;
417421
}
418422

@@ -423,7 +427,9 @@ void BaseTextProps::appendTextAttributesProps(
423427
: nullptr;
424428
}
425429

426-
if (textAttributes.letterSpacing != oldProps->textAttributes.letterSpacing) {
430+
if (!floatEquality(
431+
textAttributes.letterSpacing,
432+
oldProps->textAttributes.letterSpacing)) {
427433
result["letterSpacing"] = textAttributes.letterSpacing;
428434
}
429435

@@ -440,7 +446,8 @@ void BaseTextProps::appendTextAttributesProps(
440446
: nullptr;
441447
}
442448

443-
if (textAttributes.lineHeight != oldProps->textAttributes.lineHeight) {
449+
if (!floatEquality(
450+
textAttributes.lineHeight, oldProps->textAttributes.lineHeight)) {
444451
result["lineHeight"] = textAttributes.lineHeight;
445452
}
446453

@@ -500,8 +507,9 @@ void BaseTextProps::appendTextAttributesProps(
500507
: nullptr;
501508
}
502509

503-
if (textAttributes.textShadowRadius !=
504-
oldProps->textAttributes.textShadowRadius) {
510+
if (!floatEquality(
511+
textAttributes.textShadowRadius,
512+
oldProps->textAttributes.textShadowRadius)) {
505513
result["textShadowRadius"] = textAttributes.textShadowRadius;
506514
}
507515

0 commit comments

Comments
 (0)