mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make it easier for user to toggle only Fabric or TurboModules in New Architecture (#35091)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35091 This diff refines the DefaultNewArchitectureEntryPoint to make it easier for user to either turn on Fabric, TurboModules or both. Changelog: [Internal] [Changed] - Make it easier for user to toggle only Fabric or TurboModules in New Architecture Reviewed By: cipolleschi Differential Revision: D40710596 fbshipit-source-id: 236060b2ebccb1bf25e7f5c0fc15f54c5ce5f608
This commit is contained in:
committed by
Facebook GitHub Bot
parent
51d14b9dbd
commit
1069841837
@@ -15,8 +15,8 @@ import com.facebook.react.fabric.ComponentFactory
|
||||
* A utility class that provides users a ComponentRegistry they can customize with a C++
|
||||
* implementation of its native methods.
|
||||
*
|
||||
* This class works together with the [DefaultNativeEntryPoint] and it's C++ implementation is
|
||||
* hosted inside the React Native framework
|
||||
* This class works together with the [DefaultNewArchitectureEntryPoint] and it's C++ implementation
|
||||
* is hosted inside the React Native framework
|
||||
*/
|
||||
@DoNotStrip
|
||||
class DefaultComponentsRegistry
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.defaults
|
||||
|
||||
import com.facebook.soloader.SoLoader
|
||||
|
||||
/**
|
||||
* A utility class that serves as an entry point for users to register all the custom Fabric
|
||||
* Components and Turbo Native Modules.
|
||||
*
|
||||
* This class needs to be invoked as `DefaultNativeEntryPoint.load("...")` by passing the name of
|
||||
* the dynamic library to load.
|
||||
*
|
||||
* By default it loads a library called `appmodules`. `appmodules` is a convention used to refer to
|
||||
* the application dynamic library. If changed here should be updated also inside the template.
|
||||
*/
|
||||
object DefaultNativeEntryPoint {
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun load(dynamicLibraryName: String = "appmodules") {
|
||||
SoLoader.loadLibrary("react_newarchdefaults")
|
||||
SoLoader.loadLibrary(dynamicLibraryName)
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.defaults
|
||||
|
||||
import com.facebook.react.config.ReactFeatureFlags
|
||||
import com.facebook.soloader.SoLoader
|
||||
|
||||
/**
|
||||
* A utility class that serves as an entry point for users setup the New Architecture.
|
||||
*
|
||||
* This class needs to be invoked as `DefaultNewArchitectureEntryPoint.load(...)` by passing a
|
||||
* series of optional parameters.
|
||||
*
|
||||
* By default it loads a library called `appmodules`. `appmodules` is a convention used to refer to
|
||||
* the application dynamic library. If changed here should be updated also inside the template.
|
||||
*
|
||||
* By default it also enables both TurboModules, Fabric and Concurrent React (aka React 18)
|
||||
*/
|
||||
object DefaultNewArchitectureEntryPoint {
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun load(
|
||||
dynamicLibraryName: String = "appmodules",
|
||||
turboModulesEnabled: Boolean = true,
|
||||
fabricEnabled: Boolean = true,
|
||||
concurrentReactEnabled: Boolean = true
|
||||
) {
|
||||
ReactFeatureFlags.useTurboModules = turboModulesEnabled
|
||||
ReactFeatureFlags.enableFabricRenderer = fabricEnabled
|
||||
|
||||
this.fabricEnabled = fabricEnabled
|
||||
this.turboModulesEnabled = turboModulesEnabled
|
||||
this.concurrentReactEnabled = concurrentReactEnabled
|
||||
|
||||
SoLoader.loadLibrary("react_newarchdefaults")
|
||||
SoLoader.loadLibrary(dynamicLibraryName)
|
||||
}
|
||||
|
||||
@JvmStatic var fabricEnabled: Boolean = false
|
||||
|
||||
@JvmStatic var turboModulesEnabled: Boolean = false
|
||||
|
||||
@JvmStatic var concurrentReactEnabled: Boolean = false
|
||||
}
|
||||
+2
-2
@@ -17,8 +17,8 @@ import com.facebook.react.bridge.ReactApplicationContext
|
||||
* A utility class that allows you to simplify the setup of a
|
||||
* [ReactPackageTurboModuleManagerDelegate] for new apps in Open Source.
|
||||
*
|
||||
* This class works together with the [DefaultNativeEntryPoint] and it's C++ implementation is
|
||||
* hosted inside the React Native framework
|
||||
* This class works together with the [DefaultNewArchitectureEntryPoint] and it's C++ implementation
|
||||
* is hosted inside the React Native framework
|
||||
*/
|
||||
class DefaultTurboModuleManagerDelegate
|
||||
private constructor(context: ReactApplicationContext, packages: List<ReactPackage>) :
|
||||
|
||||
Reference in New Issue
Block a user