Skip to content

Commit 571a0ae

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add getDiffProps for Text component (facebook#51218)
Summary: Pull Request resolved: facebook#51218 See title Changelog: [Internal] Reviewed By: javache Differential Revision: D74473101 fbshipit-source-id: 7303a8b184f42e8b264a2d37c5a6570252c64d54
1 parent 0cdf5c1 commit 571a0ae

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ jni::local_ref<jobject> getProps(
226226
(strcmp(newShadowView.componentName, "View") == 0 ||
227227
strcmp(newShadowView.componentName, "Image") == 0 ||
228228
strcmp(newShadowView.componentName, "ScrollView") == 0 ||
229-
strcmp(newShadowView.componentName, "RawText") == 0)) {
229+
strcmp(newShadowView.componentName, "RawText") == 0 ||
230+
strcmp(newShadowView.componentName, "Text") == 0)) {
230231
return ReadableNativeMap::newObjectCxxArgs(
231232
newProps->getDiffProps(oldProps));
232233
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,21 @@ SharedDebugStringConvertibleList TextProps::getDebugProps() const {
3333
}
3434
#endif
3535

36+
#ifdef ANDROID
37+
38+
folly::dynamic TextProps::getDiffProps(const Props* prevProps) const {
39+
folly::dynamic result = folly::dynamic::object();
40+
41+
static const auto defaultProps = TextProps();
42+
43+
const TextProps* oldProps = prevProps == nullptr
44+
? &defaultProps
45+
: static_cast<const TextProps*>(prevProps);
46+
47+
BaseTextProps::appendTextAttributesProps(result, oldProps);
48+
49+
return result;
50+
}
51+
52+
#endif
3653
} // namespace facebook::react

packages/react-native/ReactCommon/react/renderer/components/text/TextProps.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ class TextProps : public Props, public BaseTextProps {
3434
#if RN_DEBUG_STRING_CONVERTIBLE
3535
SharedDebugStringConvertibleList getDebugProps() const override;
3636
#endif
37+
38+
#ifdef ANDROID
39+
40+
folly::dynamic getDiffProps(const Props* prevProps) const override;
41+
42+
#endif
3743
};
3844

3945
} // namespace facebook::react

0 commit comments

Comments
 (0)