diff --git a/packages/react-native-renderer/src/ReactNativeAttributePayload.js b/packages/react-native-renderer/src/ReactNativeAttributePayload.js index 68ba068308b9c..0b316ff1ab875 100644 --- a/packages/react-native-renderer/src/ReactNativeAttributePayload.js +++ b/packages/react-native-renderer/src/ReactNativeAttributePayload.js @@ -14,6 +14,8 @@ import { } from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'; import isArray from 'shared/isArray'; +import {enableEarlyReturnForPropDiffing} from 'shared/ReactFeatureFlags'; + import type {AttributeConfiguration} from './ReactNativeTypes'; const emptyObject = {}; @@ -483,6 +485,11 @@ export function diff( nextProps: Object, validAttributes: AttributeConfiguration, ): null | Object { + if (enableEarlyReturnForPropDiffing) { + if (prevProps === nextProps) { + return null; // no change + } + } return diffProperties( null, // updatePayload prevProps, diff --git a/packages/shared/ReactFeatureFlags.js b/packages/shared/ReactFeatureFlags.js index 02c4abc3a85de..cc1061c372621 100644 --- a/packages/shared/ReactFeatureFlags.js +++ b/packages/shared/ReactFeatureFlags.js @@ -119,6 +119,8 @@ export const passChildrenWhenCloningPersistedNodes = false; export const enableServerComponentLogs = __EXPERIMENTAL__; +export const enableEarlyReturnForPropDiffing = false; + /** * Enables an expiration time for retry lanes to avoid starvation. */ diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js b/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js index f024eb4b1cd87..2a730a71e15cd 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb-dynamic.js @@ -20,6 +20,7 @@ export const alwaysThrottleRetries = __VARIANT__; export const consoleManagedByDevToolsDuringStrictMode = __VARIANT__; export const enableAsyncActions = __VARIANT__; +export const enableEarlyReturnForPropDiffing = __VARIANT__; export const enableComponentStackLocations = __VARIANT__; export const enableDeferRootSchedulingToMicrotask = __VARIANT__; export const enableInfiniteRenderLoopDetection = __VARIANT__; diff --git a/packages/shared/forks/ReactFeatureFlags.native-fb.js b/packages/shared/forks/ReactFeatureFlags.native-fb.js index 5c29c8b9a71d8..a41dbfce439d1 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.native-fb.js @@ -22,6 +22,7 @@ export const { alwaysThrottleRetries, consoleManagedByDevToolsDuringStrictMode, enableAsyncActions, + enableEarlyReturnForPropDiffing, enableComponentStackLocations, enableDeferRootSchedulingToMicrotask, enableInfiniteRenderLoopDetection, diff --git a/packages/shared/forks/ReactFeatureFlags.native-oss.js b/packages/shared/forks/ReactFeatureFlags.native-oss.js index e1064dfa1bf59..61b7ef2f40391 100644 --- a/packages/shared/forks/ReactFeatureFlags.native-oss.js +++ b/packages/shared/forks/ReactFeatureFlags.native-oss.js @@ -101,6 +101,7 @@ export const allowConcurrentByDefault = false; export const enableTransitionTracing = false; export const enableDO_NOT_USE_disableStrictPassiveEffect = false; export const passChildrenWhenCloningPersistedNodes = false; +export const enableEarlyReturnForPropDiffing = false; // Profiling Only export const enableProfilerTimer = __PROFILE__; diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.js index b0a0c7f5d5342..ba204b9ee0e04 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.js @@ -76,6 +76,7 @@ export const disableClientCache = true; export const enableServerComponentKeys = true; export const enableServerComponentLogs = true; export const enableInfiniteRenderLoopDetection = false; +export const enableEarlyReturnForPropDiffing = false; // TODO: This must be in sync with the main ReactFeatureFlags file because // the Test Renderer's value must be the same as the one used by the diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js index 40297ad5fa620..b1755e226673f 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js @@ -87,6 +87,7 @@ export const disableLegacyMode = false; export const disableDOMTestUtils = false; export const disableDefaultPropsExceptForClasses = false; +export const enableEarlyReturnForPropDiffing = false; // Flow magic to verify the exports of this file match the original version. ((((null: any): ExportsType): FeatureFlagsType): ExportsType); diff --git a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js index 0aa61e8b9bd4e..6931c771ff8d4 100644 --- a/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +++ b/packages/shared/forks/ReactFeatureFlags.test-renderer.www.js @@ -87,6 +87,7 @@ export const disableLegacyMode = false; export const disableDOMTestUtils = false; export const disableDefaultPropsExceptForClasses = false; +export const enableEarlyReturnForPropDiffing = false; // Flow magic to verify the exports of this file match the original version. ((((null: any): ExportsType): FeatureFlagsType): ExportsType); diff --git a/packages/shared/forks/ReactFeatureFlags.www.js b/packages/shared/forks/ReactFeatureFlags.www.js index 82e3b08c7ecd0..dbf30b546c4a1 100644 --- a/packages/shared/forks/ReactFeatureFlags.www.js +++ b/packages/shared/forks/ReactFeatureFlags.www.js @@ -117,6 +117,7 @@ export const disableStringRefs = false; export const disableLegacyMode = __EXPERIMENTAL__; export const disableDOMTestUtils = false; +export const enableEarlyReturnForPropDiffing = false; // Flow magic to verify the exports of this file match the original version. ((((null: any): ExportsType): FeatureFlagsType): ExportsType);