Skip to content

Commit 536aa67

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add getDiffProps for RawText component (#51179)
Summary: Pull Request resolved: #51179 See title Changelog: [Internal] Reviewed By: rshest Differential Revision: D74365934 fbshipit-source-id: a1db8db1f3f2b63f3e3facd7070e9a12c01cbc5b
1 parent 0dbfcda commit 536aa67

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

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
@@ -225,7 +225,8 @@ jni::local_ref<jobject> getProps(
225225
if ((ReactNativeFeatureFlags::enablePropsUpdateReconciliationAndroid()) &&
226226
(strcmp(newShadowView.componentName, "View") == 0 ||
227227
strcmp(newShadowView.componentName, "Image") == 0 ||
228-
strcmp(newShadowView.componentName, "ScrollView") == 0)) {
228+
strcmp(newShadowView.componentName, "ScrollView") == 0 ||
229+
strcmp(newShadowView.componentName, "RawText") == 0)) {
229230
return ReadableNativeMap::newObjectCxxArgs(
230231
newProps->getDiffProps(oldProps));
231232
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,28 @@ SharedDebugStringConvertibleList RawTextProps::getDebugProps() const {
2828
}
2929
#endif
3030

31+
#ifdef ANDROID
32+
33+
folly::dynamic RawTextProps::getDiffProps(const Props* prevProps) const {
34+
folly::dynamic result = folly::dynamic::object();
35+
36+
static const auto defaultProps = RawTextProps();
37+
38+
const RawTextProps* oldProps = prevProps == nullptr
39+
? &defaultProps
40+
: static_cast<const RawTextProps*>(prevProps);
41+
42+
if (this == oldProps) {
43+
return result;
44+
}
45+
46+
if (text != oldProps->text) {
47+
result["text"] = text;
48+
}
49+
50+
return result;
51+
}
52+
53+
#endif
54+
3155
} // namespace facebook::react

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ class RawTextProps : public Props {
3636
#if RN_DEBUG_STRING_CONVERTIBLE
3737
SharedDebugStringConvertibleList getDebugProps() const override;
3838
#endif
39+
40+
#ifdef ANDROID
41+
42+
folly::dynamic getDiffProps(const Props* prevProps) const override;
43+
44+
#endif
3945
};
4046

4147
} // namespace facebook::react

0 commit comments

Comments
 (0)