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: https://github.com/facebook/react-native/issues/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
This commit is contained in:
David Vacca
2021-05-06 12:12:10 -07:00
committed by Lorenzo Sciandra
parent a05d179b6a
commit d894163662
@@ -86,9 +86,18 @@ public class UIManagerHelper {
}
}
CatalystInstance catalystInstance = context.getCatalystInstance();
return uiManagerType == FABRIC
? (UIManager) catalystInstance.getJSIModule(JSIModuleType.UIManager)
: catalystInstance.getNativeModule(UIManagerModule.class);
try {
return uiManagerType == FABRIC
? (UIManager) catalystInstance.getJSIModule(JSIModuleType.UIManager)
: catalystInstance.getNativeModule(UIManagerModule.class);
} catch (IllegalArgumentException ex) {
// TODO T67518514 Clean this up once we migrate everything over to bridgeless mode
ReactSoftException.logSoftException(
"UIManagerHelper",
new ReactNoCrashSoftException(
"Cannot get UIManager for UIManagerType: " + uiManagerType));
return catalystInstance.getNativeModule(UIManagerModule.class);
}
}
/**