Skip to content

Commit 4166cc0

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Fix NaN value comparison for paragraph props diffing (facebook#51289)
Summary: Pull Request resolved: facebook#51289 Because NaN is always different from NaN, these Float props were always included in the diff when set to NaN. This checks for the specific case where both the current and the prev prop value is NaN. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D74647582 fbshipit-source-id: 7941dcc6a96bed13c2e43232606bd1f9a9179606
1 parent 3e3f8ea commit 4166cc0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,21 @@ folly::dynamic ParagraphProps::getDiffProps(const Props* prevProps) const {
186186
result["adjustsFontSizeToFit"] = paragraphAttributes.adjustsFontSizeToFit;
187187
}
188188

189-
if (paragraphAttributes.minimumFontScale !=
190-
oldProps->paragraphAttributes.minimumFontScale) {
189+
if (!floatEquality(
190+
paragraphAttributes.minimumFontScale,
191+
oldProps->paragraphAttributes.minimumFontScale)) {
191192
result["minimumFontScale"] = paragraphAttributes.minimumFontScale;
192193
}
193194

194-
if (paragraphAttributes.minimumFontSize !=
195-
oldProps->paragraphAttributes.minimumFontSize) {
195+
if (!floatEquality(
196+
paragraphAttributes.minimumFontSize,
197+
oldProps->paragraphAttributes.minimumFontSize)) {
196198
result["minimumFontSize"] = paragraphAttributes.minimumFontSize;
197199
}
198200

199-
if (paragraphAttributes.maximumFontSize !=
200-
oldProps->paragraphAttributes.maximumFontSize) {
201+
if (!floatEquality(
202+
paragraphAttributes.maximumFontSize,
203+
oldProps->paragraphAttributes.maximumFontSize)) {
201204
result["maximumFontSize"] = paragraphAttributes.maximumFontSize;
202205
}
203206

0 commit comments

Comments
 (0)