Skip to content

Commit

Permalink
Refactor DefaultReactNativeHost to use the new way of Fabric initiali…
Browse files Browse the repository at this point in the history
…zation (#41374)

Summary:
Pull Request resolved: #41374

Refactoring `DefaultReactNativeHost` to use the new way of Fabric initialization through `FabricUIManagerProviderImpl`

Changelog:
[Internal] internal

Reviewed By: philIip, luluwu2032

Differential Revision: D50926872

fbshipit-source-id: be2bcea7b2ce7cb1b3f903dc92fcd2c91be267da
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Nov 10, 2023
1 parent 153a264 commit eb3ee4d
Showing 1 changed file with 11 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ import com.facebook.react.ReactHost
import com.facebook.react.ReactInstanceManager
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackageTurboModuleManagerDelegate
import com.facebook.react.bridge.JSIModulePackage
import com.facebook.react.bridge.JSIModuleProvider
import com.facebook.react.bridge.JSIModuleSpec
import com.facebook.react.bridge.JSIModuleType
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.UIManager
import com.facebook.react.bridge.UIManagerProvider
import com.facebook.react.fabric.ComponentFactory
import com.facebook.react.fabric.FabricUIManagerProviderImpl
import com.facebook.react.fabric.ReactNativeConfig
Expand All @@ -46,30 +42,20 @@ protected constructor(
null
}

override fun getJSIModulePackage(): JSIModulePackage? =
override fun getUIManagerProvider(): UIManagerProvider? =
if (isNewArchEnabled) {
JSIModulePackage { reactApplicationContext: ReactApplicationContext, _ ->
listOf(
object : JSIModuleSpec<UIManager> {
override fun getJSIModuleType(): JSIModuleType = JSIModuleType.UIManager
UIManagerProvider { reactApplicationContext: ReactApplicationContext ->
val componentFactory = ComponentFactory()

override fun getJSIModuleProvider(): JSIModuleProvider<UIManager> {
val componentFactory = ComponentFactory()
DefaultComponentsRegistry.register(componentFactory)

DefaultComponentsRegistry.register(componentFactory)
val reactInstanceManager: ReactInstanceManager = getReactInstanceManager()

val reactInstanceManager: ReactInstanceManager = getReactInstanceManager()

val viewManagers =
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext)
val viewManagerRegistry = ViewManagerRegistry(viewManagers)
return FabricUIManagerProviderImpl(
reactApplicationContext,
componentFactory,
ReactNativeConfig.DEFAULT_CONFIG,
viewManagerRegistry)
}
})
val viewManagers = reactInstanceManager.getOrCreateViewManagers(reactApplicationContext)
val viewManagerRegistry = ViewManagerRegistry(viewManagers)
FabricUIManagerProviderImpl(
componentFactory, ReactNativeConfig.DEFAULT_CONFIG, viewManagerRegistry)
.createUIManager(reactApplicationContext)
}
} else {
null
Expand Down

0 comments on commit eb3ee4d

Please sign in to comment.