Skip to content

Commit 1045b22

Browse files
Removing Fabric check from UIManagerProvider (#41982)
Summary: Pull Request resolved: #41982 Moving the check for Fabric i.e. `ReactFeatureFlags.enableFabricRenderer` to old JSI Module path logic instead of new UIManagerProvider path for Fabric initialization and changing the default of UIManagerProvider from `null` -> `reactApplicationContext -> null;` since we are adding null check on the returned `UIManager` Slight change of design of API for JSI Module in order to address the issues faced due to `ReactFeatureFlags.enableFabricRenderer`, 1. Getting rid of this check for the new Fabric initialization and keeping the old JSI Module path intact. 2. Allowing the UIManager to be nullable so as to allow Twilight surface not have UIManager set even though they it succeeds in initializing the TwilightJSIModule. 3. As made the UIManager nullable, added the null check for the same. 4. This eradicates the dependency on this flag for Anna as well. Reviewed By: christophpurrer Differential Revision: D52273097 fbshipit-source-id: bdf8b1de3771250c987c8f8bd4e48192f67a1afa
1 parent 43826fa commit 1045b22

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,14 +1406,14 @@ private ReactApplicationContext createReactContext(
14061406
mJSIModulePackage.getJSIModules(
14071407
reactContext, catalystInstance.getJavaScriptContextHolder()));
14081408
}
1409-
if (ReactFeatureFlags.enableFabricRenderer) {
1410-
if (mUIManagerProvider != null) {
1411-
UIManager uiManager = mUIManagerProvider.createUIManager(reactContext);
1409+
if (mUIManagerProvider != null) {
1410+
UIManager uiManager = mUIManagerProvider.createUIManager(reactContext);
1411+
if (uiManager != null) {
14121412
uiManager.initialize();
14131413
catalystInstance.setFabricUIManager(uiManager);
1414-
} else {
1415-
catalystInstance.getJSIModule(JSIModuleType.UIManager);
14161414
}
1415+
} else if (ReactFeatureFlags.enableFabricRenderer) {
1416+
catalystInstance.getJSIModule(JSIModuleType.UIManager);
14171417
}
14181418
if (mBridgeIdleDebugListener != null) {
14191419
catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener);

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected final Application getApplication() {
132132
}
133133

134134
protected @Nullable UIManagerProvider getUIManagerProvider() {
135-
return null;
135+
return reactApplicationContext -> null;
136136
}
137137

138138
/** Returns whether or not to treat it as normal if Activity is null. */

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManagerProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ import com.facebook.react.common.annotations.DeprecatedInNewArchitecture
1818
fun interface UIManagerProvider {
1919

2020
/* Provides a {@link com.facebook.react.bridge.UIManager} for the context received as a parameter. */
21-
fun createUIManager(context: ReactApplicationContext): UIManager
21+
fun createUIManager(context: ReactApplicationContext): UIManager?
2222
}

0 commit comments

Comments
 (0)