Create featureflag viewTransitionEnabled (#55537)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55537

Changelog:
[General] [Added] - Create featureflag viewTransitionEnabled

This diff adds a new React Native feature flag `viewTransitionEnabled` to gate the View Transition API feature.

The View Transition API enables animated transitions between views, providing a smooth visual experience when navigating between screens or updating UI elements. This flag allows the feature to be gradually rolled out and tested before full enablement.

The flag is added across all platform layers:
- JavaScript (ReactNativeFeatureFlags.js, NativeReactNativeFeatureFlags.js)
- Android Kotlin (ReactNativeFeatureFlags.kt, provider, accessor, defaults)
- C++/JNI (ReactNativeFeatureFlags.cpp/h, JReactNativeFeatureFlagsCxxInterop)
- Feature flag config (ReactNativeFeatureFlags.config.js)

Default value is `false` to ensure the feature is opt-in during experimentation.

Reviewed By: NickGerleman

Differential Revision: D92713074

fbshipit-source-id: cd9e567df3135f99c8a931fffab655f16883cf94
This commit is contained in:
Zeya Peng authored and meta-codesync[bot] committed 2026-02-12 13:32:14 -08:00
1 parent b97ca6eacf
commit d7a1d080c2
20 files changed
+138 -21

No files matched your search

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<049cc0a1aa5ab53ad2ab11c359f49827>>
* @generated SignedSource<<4549fc9a4f431306b7dc70ef3903b8fd>>
*/
/**
@@ -504,6 +504,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun viewCullingOutsetRatio(): Double = accessor.viewCullingOutsetRatio()
/**
* Enable the View Transition API for animating transitions between views.
*/
@JvmStatic
public fun viewTransitionEnabled(): Boolean = accessor.viewTransitionEnabled()
/**
* Initial prerender ratio for VirtualView.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<6d1fc28e24576c1a63dceaa8c974cc1f>>
* @generated SignedSource<<0db6bbb173a96ab07c80a3fbe43671b3>>
*/
/**
@@ -99,6 +99,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var useTurboModuleInteropCache: Boolean? = null
private var useTurboModulesCache: Boolean? = null
private var viewCullingOutsetRatioCache: Double? = null
private var viewTransitionEnabledCache: Boolean? = null
private var virtualViewPrerenderRatioCache: Double? = null
override fun commonTestFlag(): Boolean {
@@ -812,6 +813,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun viewTransitionEnabled(): Boolean {
var cached = viewTransitionEnabledCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.viewTransitionEnabled()
viewTransitionEnabledCache = cached
}
return cached
}
override fun virtualViewPrerenderRatio(): Double {
var cached = virtualViewPrerenderRatioCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<26410c9e406969734991456f635be4af>>
* @generated SignedSource<<ec247759261e831159a6f7781bf44998>>
*/
/**
@@ -186,6 +186,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun viewCullingOutsetRatio(): Double
@DoNotStrip @JvmStatic public external fun viewTransitionEnabled(): Boolean
@DoNotStrip @JvmStatic public external fun virtualViewPrerenderRatio(): Double
@DoNotStrip @JvmStatic public external fun override(provider: Any)
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<b088aaa5805b084d234c20bed0dec3ab>>
* @generated SignedSource<<102ac98a8c3f2c1a2150c223a099cf72>>
*/
/**
@@ -181,5 +181,7 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun viewCullingOutsetRatio(): Double = 0.0
override fun viewTransitionEnabled(): Boolean = false
override fun virtualViewPrerenderRatio(): Double = 5.0
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<ee633c2c40fc07aa6cbb5601dfb36cf6>>
* @generated SignedSource<<b7b29f2e01fd0bd43e6509587c862d31>>
*/
/**
@@ -103,6 +103,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var useTurboModuleInteropCache: Boolean? = null
private var useTurboModulesCache: Boolean? = null
private var viewCullingOutsetRatioCache: Double? = null
private var viewTransitionEnabledCache: Boolean? = null
private var virtualViewPrerenderRatioCache: Double? = null
override fun commonTestFlag(): Boolean {
@@ -895,6 +896,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}
override fun viewTransitionEnabled(): Boolean {
var cached = viewTransitionEnabledCache
if (cached == null) {
cached = currentProvider.viewTransitionEnabled()
accessedFeatureFlags.add("viewTransitionEnabled")
viewTransitionEnabledCache = cached
}
return cached
}
override fun virtualViewPrerenderRatio(): Double {
var cached = virtualViewPrerenderRatioCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<fa7f50fd466b7cb65b208c0b0aaec704>>
* @generated SignedSource<<50f2ea7e87e80a247b6c6ce8e2afd0ec>>
*/
/**
@@ -181,5 +181,7 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun viewCullingOutsetRatio(): Double
@DoNotStrip public fun viewTransitionEnabled(): Boolean
@DoNotStrip public fun virtualViewPrerenderRatio(): Double
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<698b775afb6ad9295c181ea3d12118d3>>
* @generated SignedSource<<0460a8b25bfb176e47fb12dc091b1961>>
*/
/**
@@ -513,6 +513,12 @@ class ReactNativeFeatureFlagsJavaProvider
return method(javaProvider_);
}
bool viewTransitionEnabled() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("viewTransitionEnabled");
return method(javaProvider_);
}
double virtualViewPrerenderRatio() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jdouble()>("virtualViewPrerenderRatio");
@@ -918,6 +924,11 @@ double JReactNativeFeatureFlagsCxxInterop::viewCullingOutsetRatio(
return ReactNativeFeatureFlags::viewCullingOutsetRatio();
}
bool JReactNativeFeatureFlagsCxxInterop::viewTransitionEnabled(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::viewTransitionEnabled();
}
double JReactNativeFeatureFlagsCxxInterop::virtualViewPrerenderRatio(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::virtualViewPrerenderRatio();
@@ -1191,6 +1202,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"viewCullingOutsetRatio",
JReactNativeFeatureFlagsCxxInterop::viewCullingOutsetRatio),
makeNativeMethod(
"viewTransitionEnabled",
JReactNativeFeatureFlagsCxxInterop::viewTransitionEnabled),
makeNativeMethod(
"virtualViewPrerenderRatio",
JReactNativeFeatureFlagsCxxInterop::virtualViewPrerenderRatio),
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<7be3a44c6ffc2c9d390f66902ef80d30>>
* @generated SignedSource<<88f40502abd13f8f57015429dd087519>>
*/
/**
@@ -267,6 +267,9 @@ class JReactNativeFeatureFlagsCxxInterop
static double viewCullingOutsetRatio(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool viewTransitionEnabled(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static double virtualViewPrerenderRatio(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<88b22330e8486a820eb42b59fb7279e4>>
* @generated SignedSource<<d96b2f1e4083046cfc061317d117e762>>
*/
/**
@@ -342,6 +342,10 @@ double ReactNativeFeatureFlags::viewCullingOutsetRatio() {
return getAccessor().viewCullingOutsetRatio();
}
bool ReactNativeFeatureFlags::viewTransitionEnabled() {
return getAccessor().viewTransitionEnabled();
}
double ReactNativeFeatureFlags::virtualViewPrerenderRatio() {
return getAccessor().virtualViewPrerenderRatio();
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<af0f34b904e1e555e18f186fb44ca089>>
* @generated SignedSource<<51a4817654c04c979a33f44e42312dd5>>
*/
/**
@@ -434,6 +434,11 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static double viewCullingOutsetRatio();
/**
* Enable the View Transition API for animating transitions between views.
*/
RN_EXPORT static bool viewTransitionEnabled();
/**
* Initial prerender ratio for VirtualView.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<65ca2267e4bd81dcc21f35bbfc880ba8>>
* @generated SignedSource<<fe15bc49fc0e101efb3f7a42f0c3312f>>
*/
/**
@@ -1451,6 +1451,24 @@ double ReactNativeFeatureFlagsAccessor::viewCullingOutsetRatio() {
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::viewTransitionEnabled() {
auto flagValue = viewTransitionEnabled_.load();
if (!flagValue.has_value()) {
// This block is not exclusive but it is not necessary.
// If multiple threads try to initialize the feature flag, we would only
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(79, "viewTransitionEnabled");
flagValue = currentProvider_->viewTransitionEnabled();
viewTransitionEnabled_ = flagValue;
}
return flagValue.value();
}
double ReactNativeFeatureFlagsAccessor::virtualViewPrerenderRatio() {
auto flagValue = virtualViewPrerenderRatio_.load();
@@ -1460,7 +1478,7 @@ double ReactNativeFeatureFlagsAccessor::virtualViewPrerenderRatio() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(79, "virtualViewPrerenderRatio");
markFlagAsAccessed(80, "virtualViewPrerenderRatio");
flagValue = currentProvider_->virtualViewPrerenderRatio();
virtualViewPrerenderRatio_ = flagValue;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<1aed21628664154ea7f66f15b1f760c2>>
* @generated SignedSource<<545708e361d01a42b3aef51ba71d646d>>
*/
/**
@@ -111,6 +111,7 @@ class ReactNativeFeatureFlagsAccessor {
bool useTurboModuleInterop();
bool useTurboModules();
double viewCullingOutsetRatio();
bool viewTransitionEnabled();
double virtualViewPrerenderRatio();
void override(std::unique_ptr<ReactNativeFeatureFlagsProvider> provider);
@@ -123,7 +124,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;
std::array<std::atomic<const char*>, 80> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 81> accessedFeatureFlags_;
std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> cdpInteractionMetricsEnabled_;
@@ -204,6 +205,7 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> useTurboModuleInterop_;
std::atomic<std::optional<bool>> useTurboModules_;
std::atomic<std::optional<double>> viewCullingOutsetRatio_;
std::atomic<std::optional<bool>> viewTransitionEnabled_;
std::atomic<std::optional<double>> virtualViewPrerenderRatio_;
};
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<f76c973356dda6266d01ed105c62572c>>
* @generated SignedSource<<777478fa4d8beba140a30edb68cc34d9>>
*/
/**
@@ -343,6 +343,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return 0.0;
}
bool viewTransitionEnabled() override {
return false;
}
double virtualViewPrerenderRatio() override {
return 5.0;
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<c4c17217a988345ecea40923a944712b>>
* @generated SignedSource<<55247339124401e105501f3d9d3b5b92>>
*/
/**
@@ -756,6 +756,15 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef
return ReactNativeFeatureFlagsDefaults::viewCullingOutsetRatio();
}
bool viewTransitionEnabled() override {
auto value = values_["viewTransitionEnabled"];
if (!value.isNull()) {
return value.getBool();
}
return ReactNativeFeatureFlagsDefaults::viewTransitionEnabled();
}
double virtualViewPrerenderRatio() override {
auto value = values_["virtualViewPrerenderRatio"];
if (!value.isNull()) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<0308cb63246c4576859383adc3cc9593>>
* @generated SignedSource<<05c9d90f759f2a6116219a1e61eeee82>>
*/
/**
@@ -104,6 +104,7 @@ class ReactNativeFeatureFlagsProvider {
virtual bool useTurboModuleInterop() = 0;
virtual bool useTurboModules() = 0;
virtual double viewCullingOutsetRatio() = 0;
virtual bool viewTransitionEnabled() = 0;
virtual double virtualViewPrerenderRatio() = 0;
};
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<f0c4b2e07f64b4b0850748e641ca0069>>
* @generated SignedSource<<39413a3a4416946e3ade57074664492d>>
*/
/**
@@ -439,6 +439,11 @@ double NativeReactNativeFeatureFlags::viewCullingOutsetRatio(
return ReactNativeFeatureFlags::viewCullingOutsetRatio();
}
bool NativeReactNativeFeatureFlags::viewTransitionEnabled(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::viewTransitionEnabled();
}
double NativeReactNativeFeatureFlags::virtualViewPrerenderRatio(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::virtualViewPrerenderRatio();
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<1fa17a0bb7f29a34541d362d1ecdc788>>
* @generated SignedSource<<6ed865d409cf5df84607ffa599e46fe7>>
*/
/**
@@ -194,6 +194,8 @@ class NativeReactNativeFeatureFlags
double viewCullingOutsetRatio(jsi::Runtime& runtime);
bool viewTransitionEnabled(jsi::Runtime& runtime);
double virtualViewPrerenderRatio(jsi::Runtime& runtime);
};
@@ -890,6 +890,17 @@ const definitions: FeatureFlagDefinitions = {
},
ossReleaseStage: 'none',
},
viewTransitionEnabled: {
defaultValue: false,
metadata: {
dateAdded: '2026-02-09',
description:
'Enable the View Transition API for animating transitions between views.',
expectedReleaseValue: true,
purpose: 'experimentation',
},
ossReleaseStage: 'none',
},
virtualViewPrerenderRatio: {
defaultValue: 5,
metadata: {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<f55cb510ee44b95371cf36527fe5ac01>>
* @generated SignedSource<<f185f3dcae022c810658c23f4a5dd732>>
* @flow strict
* @noformat
*/
@@ -126,6 +126,7 @@ export type ReactNativeFeatureFlags = $ReadOnly<{
useTurboModuleInterop: Getter<boolean>,
useTurboModules: Getter<boolean>,
viewCullingOutsetRatio: Getter<number>,
viewTransitionEnabled: Getter<boolean>,
virtualViewPrerenderRatio: Getter<number>,
}>;
@@ -509,6 +510,10 @@ export const useTurboModules: Getter<boolean> = createNativeFlagGetter('useTurbo
* Outset the culling context frame with the provided ratio. The culling context frame size will be outset by width * ratio on the left and right, and height * ratio on the top and bottom.
*/
export const viewCullingOutsetRatio: Getter<number> = createNativeFlagGetter('viewCullingOutsetRatio', 0);
/**
* Enable the View Transition API for animating transitions between views.
*/
export const viewTransitionEnabled: Getter<boolean> = createNativeFlagGetter('viewTransitionEnabled', false);
/**
* Initial prerender ratio for VirtualView.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<b98b482f38efbeeab9f8dc6aec9e62ba>>
* @generated SignedSource<<1fe995d928d6ea2770936cdd6e2b8320>>
* @flow strict
* @noformat
*/
@@ -104,6 +104,7 @@ export interface Spec extends TurboModule {
+useTurboModuleInterop?: () => boolean;
+useTurboModules?: () => boolean;
+viewCullingOutsetRatio?: () => number;
+viewTransitionEnabled?: () => boolean;
+virtualViewPrerenderRatio?: () => number;
}