Skip to content

Commit

Permalink
Introduce getDiffProps for <View> (#45552)
Browse files Browse the repository at this point in the history
Summary:

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
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jan 7, 2025
1 parent 7a58f1f commit 2e0bd06
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,25 @@ SharedDebugStringConvertibleList HostPlatformViewProps::getDebugProps() const {
}
#endif

#ifdef ANDROID

folly::dynamic HostPlatformViewProps::getDiffProps(
const Props* prevProps) const {
folly::dynamic result = folly::dynamic::object();

static const auto defaultProps = HostPlatformViewProps();

const HostPlatformViewProps* oldProps = prevProps == nullptr
? &defaultProps
: static_cast<const HostPlatformViewProps*>(prevProps);

if (focusable != oldProps->focusable) {
result["focusable"] = focusable;
}

return result;
}

#endif

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class HostPlatformViewProps : public BaseViewProps {
#if RN_DEBUG_STRING_CONVERTIBLE
SharedDebugStringConvertibleList getDebugProps() const override;
#endif

#ifdef ANDROID

folly::dynamic getDiffProps(const Props* prevProps) const override;

#endif
};

} // namespace facebook::react

0 comments on commit 2e0bd06

Please sign in to comment.