Part 2: Make CatalystInstanceImpl.getNativeModule Nullable

Summary:
This is the codemod portion of the parent diff.

I modified all call-sites to `ReactContext.getNativeModule` to do a null check on the returned NativeModule.

Changelog:
[Android][Fixed] - Check if NativeModules returned from CatalystInstanceImpl.getNativeModule are null before using them.

Reviewed By: JoshuaGross

Differential Revision: D21272028

fbshipit-source-id: 6bd16c6bf30605f2dfdf4c481352063712965342
This commit is contained in:
Ramanpreet Nara authored and Facebook GitHub Bot committed 2020-04-28 12:18:17 -07:00
1 parent 1cef72af04
commit 9263eb5d38
20 files changed
+153 -72

No files matched your search

@@ -8,6 +8,7 @@
package com.facebook.react.fabric;
import androidx.annotation.NonNull;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.JSIModuleProvider;
import com.facebook.react.bridge.JavaScriptContextHolder;
import com.facebook.react.bridge.ReactApplicationContext;
@@ -83,7 +84,8 @@ public class FabricJSIModuleProvider implements JSIModuleProvider<UIManager> {
private FabricUIManager createUIManager(@NonNull EventBeatManager eventBeatManager) {
Systrace.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.createUIManager");
UIManagerModule nativeModule = mReactApplicationContext.getNativeModule(UIManagerModule.class);
UIManagerModule nativeModule =
Assertions.assertNotNull(mReactApplicationContext.getNativeModule(UIManagerModule.class));
EventDispatcher eventDispatcher = nativeModule.getEventDispatcher();
FabricUIManager fabricUIManager =
new FabricUIManager(