Skip to content

Commit 1e16910

Browse files
Nick Lefevermeta-codesync[bot]
authored andcommitted
Add exclusive props handling feature flag (#54499)
Summary: Pull Request resolved: #54499 This feature flag disables the Props 1.5 merging for props instaces that will use Props 2.0. ## Context about this change * When Props 1.5 is enabled, cloning props would always trigger the merge of raw props so that the result of multiple commits could be combined for a single mount. * Props 2.0 is enabled on core components and codegen components * When a component has support for Props 2.0, there is no need to apply the Props 1.5 merging when cloning props. Props 2.0 uses the C++ Props instance to keep track of the state of the shadow node props and diff it with the last mount. ## How is the conditional merging implemented * When a concrete shadow node needs to have the props cloned, we use the Props 2.0 implementation target to check that it matches the shadow node's component * If it matches, the props support diffing for all properties used by the component * Props 2.0 can be used to generate the mount transaction * If it doesn't match, the props were extended and additional props might have been defined which are not supported by the Props 2.0 diffing implementation * In this case we need to fallback to Props 1.5 Changelog: [Internal] Reviewed By: javache Differential Revision: D86732107 fbshipit-source-id: 7bb6f01508c564a292908ab458d499f619b9fd4b
1 parent cb7ce49 commit 1e16910

24 files changed

Lines changed: 264 additions & 96 deletions

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<35b171a16e75e3bb047139c0b8084f04>>
7+
* @generated SignedSource<<9cb554e599417e707c0953baa6adb0c2>>
88
*/
99

1010
/**
@@ -168,6 +168,12 @@ public object ReactNativeFeatureFlags {
168168
@JvmStatic
169169
public fun enableEagerRootViewAttachment(): Boolean = accessor.enableEagerRootViewAttachment()
170170

171+
/**
172+
* When enabled, Android will disable Props 1.5 raw value merging when Props 2.0 is available.
173+
*/
174+
@JvmStatic
175+
public fun enableExclusivePropsUpdateAndroid(): Boolean = accessor.enableExclusivePropsUpdateAndroid()
176+
171177
/**
172178
* This feature flag enables logs for Fabric.
173179
*/

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<2f0412d405655c1dafc7d63a8dcb0da1>>
7+
* @generated SignedSource<<24a3e681a86bce628917f5e20ce1b1eb>>
88
*/
99

1010
/**
@@ -43,6 +43,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
4343
private var enableDoubleMeasurementFixAndroidCache: Boolean? = null
4444
private var enableEagerMainQueueModulesOnIOSCache: Boolean? = null
4545
private var enableEagerRootViewAttachmentCache: Boolean? = null
46+
private var enableExclusivePropsUpdateAndroidCache: Boolean? = null
4647
private var enableFabricLogsCache: Boolean? = null
4748
private var enableFabricRendererCache: Boolean? = null
4849
private var enableFontScaleChangesUpdatingLayoutCache: Boolean? = null
@@ -314,6 +315,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
314315
return cached
315316
}
316317

318+
override fun enableExclusivePropsUpdateAndroid(): Boolean {
319+
var cached = enableExclusivePropsUpdateAndroidCache
320+
if (cached == null) {
321+
cached = ReactNativeFeatureFlagsCxxInterop.enableExclusivePropsUpdateAndroid()
322+
enableExclusivePropsUpdateAndroidCache = cached
323+
}
324+
return cached
325+
}
326+
317327
override fun enableFabricLogs(): Boolean {
318328
var cached = enableFabricLogsCache
319329
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<482e0650e142e65efdfbc394c041690d>>
7+
* @generated SignedSource<<f57b2ecf22eabb7f207b86c472059084>>
88
*/
99

1010
/**
@@ -74,6 +74,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
7474

7575
@DoNotStrip @JvmStatic public external fun enableEagerRootViewAttachment(): Boolean
7676

77+
@DoNotStrip @JvmStatic public external fun enableExclusivePropsUpdateAndroid(): Boolean
78+
7779
@DoNotStrip @JvmStatic public external fun enableFabricLogs(): Boolean
7880

7981
@DoNotStrip @JvmStatic public external fun enableFabricRenderer(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<8c75d178f645340779aed6c3e0b3f016>>
7+
* @generated SignedSource<<47b33d1a21af24f369e52d3b8f226d73>>
88
*/
99

1010
/**
@@ -69,6 +69,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
6969

7070
override fun enableEagerRootViewAttachment(): Boolean = false
7171

72+
override fun enableExclusivePropsUpdateAndroid(): Boolean = false
73+
7274
override fun enableFabricLogs(): Boolean = false
7375

7476
override fun enableFabricRenderer(): Boolean = false

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<6217268b4398764dfd0da461d93bb55a>>
7+
* @generated SignedSource<<a9c53954bffc14f69cf1e7c4707cb37a>>
88
*/
99

1010
/**
@@ -47,6 +47,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
4747
private var enableDoubleMeasurementFixAndroidCache: Boolean? = null
4848
private var enableEagerMainQueueModulesOnIOSCache: Boolean? = null
4949
private var enableEagerRootViewAttachmentCache: Boolean? = null
50+
private var enableExclusivePropsUpdateAndroidCache: Boolean? = null
5051
private var enableFabricLogsCache: Boolean? = null
5152
private var enableFabricRendererCache: Boolean? = null
5253
private var enableFontScaleChangesUpdatingLayoutCache: Boolean? = null
@@ -341,6 +342,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
341342
return cached
342343
}
343344

345+
override fun enableExclusivePropsUpdateAndroid(): Boolean {
346+
var cached = enableExclusivePropsUpdateAndroidCache
347+
if (cached == null) {
348+
cached = currentProvider.enableExclusivePropsUpdateAndroid()
349+
accessedFeatureFlags.add("enableExclusivePropsUpdateAndroid")
350+
enableExclusivePropsUpdateAndroidCache = cached
351+
}
352+
return cached
353+
}
354+
344355
override fun enableFabricLogs(): Boolean {
345356
var cached = enableFabricLogsCache
346357
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<aea4f9836bcb46f125738d92fc03664b>>
7+
* @generated SignedSource<<da5879ddbaea7cd51f828e284bc0e913>>
88
*/
99

1010
/**
@@ -69,6 +69,8 @@ public interface ReactNativeFeatureFlagsProvider {
6969

7070
@DoNotStrip public fun enableEagerRootViewAttachment(): Boolean
7171

72+
@DoNotStrip public fun enableExclusivePropsUpdateAndroid(): Boolean
73+
7274
@DoNotStrip public fun enableFabricLogs(): Boolean
7375

7476
@DoNotStrip public fun enableFabricRenderer(): Boolean

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<52f8dbc9c7975a1eb83bcb4bd4973ace>>
7+
* @generated SignedSource<<1a3267843d7400974e8686c83d359c7b>>
88
*/
99

1010
/**
@@ -177,6 +177,12 @@ class ReactNativeFeatureFlagsJavaProvider
177177
return method(javaProvider_);
178178
}
179179

180+
bool enableExclusivePropsUpdateAndroid() override {
181+
static const auto method =
182+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableExclusivePropsUpdateAndroid");
183+
return method(javaProvider_);
184+
}
185+
180186
bool enableFabricLogs() override {
181187
static const auto method =
182188
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableFabricLogs");
@@ -674,6 +680,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableEagerRootViewAttachment(
674680
return ReactNativeFeatureFlags::enableEagerRootViewAttachment();
675681
}
676682

683+
bool JReactNativeFeatureFlagsCxxInterop::enableExclusivePropsUpdateAndroid(
684+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
685+
return ReactNativeFeatureFlags::enableExclusivePropsUpdateAndroid();
686+
}
687+
677688
bool JReactNativeFeatureFlagsCxxInterop::enableFabricLogs(
678689
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
679690
return ReactNativeFeatureFlags::enableFabricLogs();
@@ -1089,6 +1100,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
10891100
makeNativeMethod(
10901101
"enableEagerRootViewAttachment",
10911102
JReactNativeFeatureFlagsCxxInterop::enableEagerRootViewAttachment),
1103+
makeNativeMethod(
1104+
"enableExclusivePropsUpdateAndroid",
1105+
JReactNativeFeatureFlagsCxxInterop::enableExclusivePropsUpdateAndroid),
10921106
makeNativeMethod(
10931107
"enableFabricLogs",
10941108
JReactNativeFeatureFlagsCxxInterop::enableFabricLogs),

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<cf83d0062141cba8907e099b01a3809f>>
7+
* @generated SignedSource<<9769e993b3481e991ef79406734b6e28>>
88
*/
99

1010
/**
@@ -99,6 +99,9 @@ class JReactNativeFeatureFlagsCxxInterop
9999
static bool enableEagerRootViewAttachment(
100100
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
101101

102+
static bool enableExclusivePropsUpdateAndroid(
103+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
104+
102105
static bool enableFabricLogs(
103106
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
104107

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<e938b14c610089a3ea008b85c54f2b1b>>
7+
* @generated SignedSource<<316d877ef7aac59c840cb2b6e659891d>>
88
*/
99

1010
/**
@@ -118,6 +118,10 @@ bool ReactNativeFeatureFlags::enableEagerRootViewAttachment() {
118118
return getAccessor().enableEagerRootViewAttachment();
119119
}
120120

121+
bool ReactNativeFeatureFlags::enableExclusivePropsUpdateAndroid() {
122+
return getAccessor().enableExclusivePropsUpdateAndroid();
123+
}
124+
121125
bool ReactNativeFeatureFlags::enableFabricLogs() {
122126
return getAccessor().enableFabricLogs();
123127
}

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<bebf3698e5e3e3899826da1ea2000171>>
7+
* @generated SignedSource<<2ff839b736c1c74b3dccefadb6e278b9>>
88
*/
99

1010
/**
@@ -154,6 +154,11 @@ class ReactNativeFeatureFlags {
154154
*/
155155
RN_EXPORT static bool enableEagerRootViewAttachment();
156156

157+
/**
158+
* When enabled, Android will disable Props 1.5 raw value merging when Props 2.0 is available.
159+
*/
160+
RN_EXPORT static bool enableExclusivePropsUpdateAndroid();
161+
157162
/**
158163
* This feature flag enables logs for Fabric.
159164
*/

0 commit comments

Comments
 (0)