Fix DefaultReactNativeHost assuming lazyViewManagers are always available (#43334)

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

cortinico flagged that bridge + fabric regressed in 0.74, likely due to D53406841.

Changelog: [Android][Fixed] Fix registration of ViewManagers in new renderer when not using lazyViewManagers.

Reviewed By: fkgozali

Differential Revision: D54551645

fbshipit-source-id: 0783030cd0d2900a3a254ae04c9ea4e51035272a
This commit is contained in:
Pieter De Baets
2024-03-06 03:11:33 -08:00
committed by Alex Hunt
parent a9ec4203e1
commit 1151ea1247
2 changed files with 16 additions and 6 deletions
@@ -998,6 +998,11 @@ public class ReactInstanceManager {
if (names != null) {
uniqueNames.addAll(names);
}
} else {
FLog.w(
ReactConstants.TAG,
"Package %s is not a ViewManagerOnDemandReactPackage, view managers will not be loaded",
reactPackage.getClass().getSimpleName());
}
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
@@ -49,13 +49,18 @@ protected constructor(
DefaultComponentsRegistry.register(componentFactory)
val viewManagerRegistry =
ViewManagerRegistry(
object : ViewManagerResolver {
override fun getViewManager(viewManagerName: String) =
reactInstanceManager.createViewManager(viewManagerName)
if (lazyViewManagersEnabled) {
ViewManagerRegistry(
object : ViewManagerResolver {
override fun getViewManager(viewManagerName: String) =
reactInstanceManager.createViewManager(viewManagerName)
override fun getViewManagerNames() = reactInstanceManager.viewManagerNames
})
override fun getViewManagerNames() = reactInstanceManager.viewManagerNames
})
} else {
ViewManagerRegistry(
reactInstanceManager.getOrCreateViewManagers(reactApplicationContext))
}
FabricUIManagerProviderImpl(
componentFactory, ReactNativeConfig.DEFAULT_CONFIG, viewManagerRegistry)