diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm index 6d159ef598a286..d79fbb42b35a92 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm @@ -11,7 +11,11 @@ #import #import #import -#import +#import +#import +#import +#import +#import "RCTAppDelegate+Protected.h" #import "RCTAppSetupUtils.h" #if RN_DISABLE_OSS_PLUGIN_HEADER @@ -46,6 +50,8 @@ @implementation RCTAppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [self _setUpFeatureFlags]; + RCTSetNewArchEnabled([self newArchEnabled]); RCTAppSetupPrepareApp(application, self.turboModuleEnabled); @@ -258,4 +264,29 @@ - (RCTRootViewFactory *)createRCTRootViewFactory return [[RCTRootViewFactory alloc] initWithConfiguration:configuration andTurboModuleManagerDelegate:self]; } +#pragma mark - Feature Flags + +class RCTAppDelegateBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults { + public: + bool useModernRuntimeScheduler() override + { + return true; + } + bool enableMicrotasks() override + { + return true; + } + bool batchRenderingUpdatesInEventLoop() override + { + return true; + } +}; + +- (void)_setUpFeatureFlags +{ + if ([self bridgelessEnabled]) { + facebook::react::ReactNativeFeatureFlags::override(std::make_unique()); + } +} + @end diff --git a/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec b/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec index 146ff1ea5ccf83..4d5bf68dc4c80f 100644 --- a/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec +++ b/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec @@ -89,6 +89,7 @@ Pod::Spec.new do |s| add_dependency(s, "React-utils") add_dependency(s, "React-debug") add_dependency(s, "React-rendererdebug") + add_dependency(s, "React-featureflags") if use_hermes s.dependency "React-hermes" diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt index 59ffe9bccb7875..051effc8525d58 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt @@ -11,6 +11,8 @@ package com.facebook.react.defaults import com.facebook.react.common.annotations.VisibleForTesting import com.facebook.react.config.ReactFeatureFlags +import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags +import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsDefaults /** * A utility class that serves as an entry point for users setup the New Architecture. @@ -45,6 +47,17 @@ public object DefaultNewArchitectureEntryPoint { ReactFeatureFlags.unstable_useTurboModuleInterop = bridgelessEnabled ReactFeatureFlags.enableFabricPendingEventQueue = fabricEnabled + if (bridgelessEnabled) { + ReactNativeFeatureFlags.override( + object : ReactNativeFeatureFlagsDefaults() { + override fun useModernRuntimeScheduler(): Boolean = true + + override fun enableMicrotasks(): Boolean = true + + override fun batchRenderingUpdatesInEventLoop(): Boolean = true + }) + } + privateFabricEnabled = fabricEnabled privateTurboModulesEnabled = turboModulesEnabled privateConcurrentReactEnabled = fabricEnabled