Skip to content

Commit b2671bd

Browse files
committed
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
1 parent bebd653 commit b2671bd

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
@@ -130,4 +130,25 @@ SharedDebugStringConvertibleList HostPlatformViewProps::getDebugProps() const {
130130
}
131131
#endif
132132

133+
#ifdef ANDROID
134+
135+
folly::dynamic HostPlatformViewProps::getDiffProps(
136+
const Props* prevProps) const {
137+
folly::dynamic result = folly::dynamic::object();
138+
139+
static const auto defaultProps = HostPlatformViewProps();
140+
141+
const HostPlatformViewProps* oldProps = prevProps == nullptr
142+
? &defaultProps
143+
: static_cast<const HostPlatformViewProps*>(prevProps);
144+
145+
if (focusable != oldProps->focusable) {
146+
result["focusable"] = focusable;
147+
}
148+
149+
return result;
150+
}
151+
152+
#endif
153+
133154
} // 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
@@ -53,6 +53,12 @@ class HostPlatformViewProps : public BaseViewProps {
5353
#if RN_DEBUG_STRING_CONVERTIBLE
5454
SharedDebugStringConvertibleList getDebugProps() const override;
5555
#endif
56+
57+
#ifdef ANDROID
58+
59+
folly::dynamic getDiffProps(const Props* prevProps) const override;
60+
61+
#endif
5662
};
5763

5864
} // namespace facebook::react

0 commit comments

Comments
 (0)