Skip to content

Commit b0e8c1e

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Refactor UIManagerHelper.getUIManager to return null when there's no UIManager registered
Summary: This diff refactors the UIManagerHelper.getUIManager method to return null when there's no UIManager registered for the uiManagerType received as a parameter. This is necessary to workaround: #31245 changelog: [changed] UIManagerHelper.getUIManager now returns null when there's no UIManager registered for the uiManagerType received as a parameter Reviewed By: fkgozali Differential Revision: D28242592 fbshipit-source-id: c3a4979bcf6e547d0f0060737e41bbf19860a984
1 parent b2e2f43 commit b0e8c1e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerHelper.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,18 @@ private static UIManager getUIManager(
8282
}
8383
}
8484
CatalystInstance catalystInstance = context.getCatalystInstance();
85-
return uiManagerType == FABRIC
86-
? (UIManager) catalystInstance.getJSIModule(JSIModuleType.UIManager)
87-
: catalystInstance.getNativeModule(UIManagerModule.class);
85+
try {
86+
return uiManagerType == FABRIC
87+
? (UIManager) catalystInstance.getJSIModule(JSIModuleType.UIManager)
88+
: catalystInstance.getNativeModule(UIManagerModule.class);
89+
} catch (IllegalArgumentException ex) {
90+
// TODO T67518514 Clean this up once we migrate everything over to bridgeless mode
91+
ReactSoftException.logSoftException(
92+
"UIManagerHelper",
93+
new ReactNoCrashSoftException(
94+
"Cannot get UIManager for UIManagerType: " + uiManagerType));
95+
return catalystInstance.getNativeModule(UIManagerModule.class);
96+
}
8897
}
8998

9099
/**

0 commit comments

Comments
 (0)