From 9af63956d2a767538dbbf5be6a38e27a55625fde Mon Sep 17 00:00:00 2001 From: David Vacca Date: Sat, 20 Jul 2024 10:23:12 -0700 Subject: [PATCH] Enable prop diffing for (#45551) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45551 This diffs toggles the new Android prop diffing mechanism for components changelog: [internal] internal Reviewed By: sammy-SC Differential Revision: D59613243 fbshipit-source-id: 79c1e4bf4f5a67fc516e5db7b9f4ffba0cb9b69b --- .../main/jni/react/fabric/FabricMountingManager.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp index 7401f8ad813103..b96133bfaf0e0b 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp @@ -220,6 +220,17 @@ static inline float scale(Float value, Float pointScaleFactor) { jni::local_ref FabricMountingManager::getProps( const ShadowView& oldShadowView, const ShadowView& newShadowView) { + auto componentName = newShadowView.componentName; + // We calculate the diffing between the props of the last mounted ShadowTree + // and the Props of the latest commited ShadowTree). ONLY for + // components when the "enablePropsUpdateReconciliationAndroid" feature flag + // is enabled. + if (ReactNativeFeatureFlags::enablePropsUpdateReconciliationAndroid() && + strcmp(componentName, "View") == 0) { + const Props* oldProps = oldShadowView.props.get(); + auto diffProps = newShadowView.props->getDiffProps(oldProps); + return ReadableNativeMap::newObjectCxxArgs(diffProps); + } return ReadableNativeMap::newObjectCxxArgs(newShadowView.props->rawProps); }