Skip to content

Commit b962646

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add feature flag for using shadow node state on clone (#50751)
Summary: Pull Request resolved: #50751 See title Changelog: [Internal] Reviewed By: rshest Differential Revision: D73067007 fbshipit-source-id: 2a67ed33ebd35ffaa3470d75ef6f695471820fa6
1 parent 539f237 commit b962646

20 files changed

Lines changed: 139 additions & 22 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<<745904568803a9ead98bc10210b38938>>
7+
* @generated SignedSource<<794bf258fbb453ea71a39c5459316a24>>
88
*/
99

1010
/**
@@ -264,6 +264,12 @@ public object ReactNativeFeatureFlags {
264264
@JvmStatic
265265
public fun useRawPropsJsiValue(): Boolean = accessor.useRawPropsJsiValue()
266266

267+
/**
268+
* Use the state stored on the source shadow node when cloning it instead of reading in the most recent state on the shadow node family.
269+
*/
270+
@JvmStatic
271+
public fun useShadowNodeStateOnClone(): Boolean = accessor.useShadowNodeStateOnClone()
272+
267273
/**
268274
* In Bridgeless mode, should legacy NativeModules use the TurboModule system?
269275
*/

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<<4f9df3bdf8c353ccbdfeea0f0d378e01>>
7+
* @generated SignedSource<<43260e9f0b5774bdb3d60915bcd28ea3>>
88
*/
99

1010
/**
@@ -59,6 +59,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
5959
private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null
6060
private var useOptimizedEventBatchingOnAndroidCache: Boolean? = null
6161
private var useRawPropsJsiValueCache: Boolean? = null
62+
private var useShadowNodeStateOnCloneCache: Boolean? = null
6263
private var useTurboModuleInteropCache: Boolean? = null
6364
private var useTurboModulesCache: Boolean? = null
6465

@@ -413,6 +414,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
413414
return cached
414415
}
415416

417+
override fun useShadowNodeStateOnClone(): Boolean {
418+
var cached = useShadowNodeStateOnCloneCache
419+
if (cached == null) {
420+
cached = ReactNativeFeatureFlagsCxxInterop.useShadowNodeStateOnClone()
421+
useShadowNodeStateOnCloneCache = cached
422+
}
423+
return cached
424+
}
425+
416426
override fun useTurboModuleInterop(): Boolean {
417427
var cached = useTurboModuleInteropCache
418428
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<<8200512b24c8ddd99e582b24e858f1f8>>
7+
* @generated SignedSource<<1f3845a6aad6babd4404adfb433f4b38>>
88
*/
99

1010
/**
@@ -106,6 +106,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
106106

107107
@DoNotStrip @JvmStatic public external fun useRawPropsJsiValue(): Boolean
108108

109+
@DoNotStrip @JvmStatic public external fun useShadowNodeStateOnClone(): Boolean
110+
109111
@DoNotStrip @JvmStatic public external fun useTurboModuleInterop(): Boolean
110112

111113
@DoNotStrip @JvmStatic public external fun useTurboModules(): 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<<92ac1a25b3c5eb4e43334e0c65e5255f>>
7+
* @generated SignedSource<<6f24701d1581b744185caaee1ca5fc06>>
88
*/
99

1010
/**
@@ -101,6 +101,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
101101

102102
override fun useRawPropsJsiValue(): Boolean = false
103103

104+
override fun useShadowNodeStateOnClone(): Boolean = false
105+
104106
override fun useTurboModuleInterop(): Boolean = false
105107

106108
override fun useTurboModules(): 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<<c7d8c0c6ff5a50925692cca2de48c537>>
7+
* @generated SignedSource<<8988a69695658c92f013e736dec8f5fc>>
88
*/
99

1010
/**
@@ -63,6 +63,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
6363
private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null
6464
private var useOptimizedEventBatchingOnAndroidCache: Boolean? = null
6565
private var useRawPropsJsiValueCache: Boolean? = null
66+
private var useShadowNodeStateOnCloneCache: Boolean? = null
6667
private var useTurboModuleInteropCache: Boolean? = null
6768
private var useTurboModulesCache: Boolean? = null
6869

@@ -456,6 +457,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
456457
return cached
457458
}
458459

460+
override fun useShadowNodeStateOnClone(): Boolean {
461+
var cached = useShadowNodeStateOnCloneCache
462+
if (cached == null) {
463+
cached = currentProvider.useShadowNodeStateOnClone()
464+
accessedFeatureFlags.add("useShadowNodeStateOnClone")
465+
useShadowNodeStateOnCloneCache = cached
466+
}
467+
return cached
468+
}
469+
459470
override fun useTurboModuleInterop(): Boolean {
460471
var cached = useTurboModuleInteropCache
461472
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<<54e0deb6c78833a3f0394d4ff2ab9562>>
7+
* @generated SignedSource<<646efad3c8769005e893ad63d78b8c6c>>
88
*/
99

1010
/**
@@ -101,6 +101,8 @@ public interface ReactNativeFeatureFlagsProvider {
101101

102102
@DoNotStrip public fun useRawPropsJsiValue(): Boolean
103103

104+
@DoNotStrip public fun useShadowNodeStateOnClone(): Boolean
105+
104106
@DoNotStrip public fun useTurboModuleInterop(): Boolean
105107

106108
@DoNotStrip public fun useTurboModules(): 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<<d944ced839aa053484befb1496749b9e>>
7+
* @generated SignedSource<<cfbc50cc7a2ce2dbff3447c697d45797>>
88
*/
99

1010
/**
@@ -273,6 +273,12 @@ class ReactNativeFeatureFlagsJavaProvider
273273
return method(javaProvider_);
274274
}
275275

276+
bool useShadowNodeStateOnClone() override {
277+
static const auto method =
278+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useShadowNodeStateOnClone");
279+
return method(javaProvider_);
280+
}
281+
276282
bool useTurboModuleInterop() override {
277283
static const auto method =
278284
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useTurboModuleInterop");
@@ -484,6 +490,11 @@ bool JReactNativeFeatureFlagsCxxInterop::useRawPropsJsiValue(
484490
return ReactNativeFeatureFlags::useRawPropsJsiValue();
485491
}
486492

493+
bool JReactNativeFeatureFlagsCxxInterop::useShadowNodeStateOnClone(
494+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
495+
return ReactNativeFeatureFlags::useShadowNodeStateOnClone();
496+
}
497+
487498
bool JReactNativeFeatureFlagsCxxInterop::useTurboModuleInterop(
488499
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
489500
return ReactNativeFeatureFlags::useTurboModuleInterop();
@@ -642,6 +653,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
642653
makeNativeMethod(
643654
"useRawPropsJsiValue",
644655
JReactNativeFeatureFlagsCxxInterop::useRawPropsJsiValue),
656+
makeNativeMethod(
657+
"useShadowNodeStateOnClone",
658+
JReactNativeFeatureFlagsCxxInterop::useShadowNodeStateOnClone),
645659
makeNativeMethod(
646660
"useTurboModuleInterop",
647661
JReactNativeFeatureFlagsCxxInterop::useTurboModuleInterop),

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<<c122826c2dd42cfb66e96e1af5c7a54a>>
7+
* @generated SignedSource<<58c3ec4bdf7b171ea6203ed100116c50>>
88
*/
99

1010
/**
@@ -147,6 +147,9 @@ class JReactNativeFeatureFlagsCxxInterop
147147
static bool useRawPropsJsiValue(
148148
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
149149

150+
static bool useShadowNodeStateOnClone(
151+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
152+
150153
static bool useTurboModuleInterop(
151154
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
152155

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<<f98498698a19d59cc4113bf6bbc0b2ea>>
7+
* @generated SignedSource<<55680628f0480fce8c955fbde539ae47>>
88
*/
99

1010
/**
@@ -182,6 +182,10 @@ bool ReactNativeFeatureFlags::useRawPropsJsiValue() {
182182
return getAccessor().useRawPropsJsiValue();
183183
}
184184

185+
bool ReactNativeFeatureFlags::useShadowNodeStateOnClone() {
186+
return getAccessor().useShadowNodeStateOnClone();
187+
}
188+
185189
bool ReactNativeFeatureFlags::useTurboModuleInterop() {
186190
return getAccessor().useTurboModuleInterop();
187191
}

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<<aa1cc3b66b13bf529e06239c018ad515>>
7+
* @generated SignedSource<<136de88435026f3bfb2d785d1a12b707>>
88
*/
99

1010
/**
@@ -234,6 +234,11 @@ class ReactNativeFeatureFlags {
234234
*/
235235
RN_EXPORT static bool useRawPropsJsiValue();
236236

237+
/**
238+
* Use the state stored on the source shadow node when cloning it instead of reading in the most recent state on the shadow node family.
239+
*/
240+
RN_EXPORT static bool useShadowNodeStateOnClone();
241+
237242
/**
238243
* In Bridgeless mode, should legacy NativeModules use the TurboModule system?
239244
*/

0 commit comments

Comments
 (0)