Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add early return to diffProperties #28842

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const {
alwaysThrottleRetries,
consoleManagedByDevToolsDuringStrictMode,
enableAsyncActions,
enableEarlyReturnForPropDiffing,
enableComponentStackLocations,
enableDeferRootSchedulingToMicrotask,
enableInfiniteRenderLoopDetection,
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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);
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);