Skip to content

Commit 115cda2

Browse files
mdvaccahannojg
authored andcommitted
Introduce getDiffProps for <View> (facebook#45552)
Summary: Pull Request resolved: facebook#45552 In this diff I'm overriding the getDiffProps for ViewProps. The goal is to verify what's the impact of calculating diffs of props in Android, starting with ViewProps. Once we verify what are the implication we will automatic implement this diffing. The full implementation of this method will be implemented in the following diffs changelog: [internal] internal Reviewed By: NickGerleman Differential Revision: D59969328 fbshipit-source-id: ce141528581e46e9ced4175dca040ddf8bed5ddb
1 parent d245a4e commit 115cda2

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,25 @@ SharedDebugStringConvertibleList HostPlatformViewProps::getDebugProps() const {
133133
}
134134
#endif
135135

136+
#ifdef ANDROID
137+
138+
folly::dynamic HostPlatformViewProps::getDiffProps(
139+
const Props* prevProps) const {
140+
folly::dynamic result = folly::dynamic::object();
141+
142+
static const auto defaultProps = HostPlatformViewProps();
143+
144+
const HostPlatformViewProps* oldProps = prevProps == nullptr
145+
? &defaultProps
146+
: static_cast<const HostPlatformViewProps*>(prevProps);
147+
148+
if (focusable != oldProps->focusable) {
149+
result["focusable"] = focusable;
150+
}
151+
152+
return result;
153+
}
154+
155+
#endif
156+
136157
} // namespace facebook::react

packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ class HostPlatformViewProps : public BaseViewProps {
5555
#if RN_DEBUG_STRING_CONVERTIBLE
5656
SharedDebugStringConvertibleList getDebugProps() const override;
5757
#endif
58+
59+
#ifdef ANDROID
60+
61+
folly::dynamic getDiffProps(const Props* prevProps) const override;
62+
63+
#endif
5864
};
5965

6066
} // namespace facebook::react

0 commit comments

Comments
 (0)