Skip to content

Commit

Permalink
Delete getJSIModule() from context (#42097)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #42097

Since we switched all apps from `getJSIModule()` to `getFabricUIManager()` from `ReactContext` and it's subclasses it's safe to delete this method.

NOTE: The fallback for FabricUIManager is still catalystInstance.getJSIModule() that's still there for backwards comptability just deleting the indirection through ReactContext

Changelog:
[Internal] Internal

Reviewed By: christophpurrer

Differential Revision: D51748655

fbshipit-source-id: dbf1a661f9e380307614662dd6079110f878d143
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Jan 2, 2024
1 parent 157cb0e commit ce54772
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -547,14 +547,6 @@ public boolean isBridgeless() {
return null;
}

public @Nullable JSIModule getJSIModule(JSIModuleType moduleType) {
if (!hasActiveReactInstance()) {
throw new IllegalStateException(
"Unable to retrieve a JSIModule if CatalystInstance is not active.");
}
return mCatalystInstance.getJSIModule(moduleType);
}

@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not encouraged usage.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.JSIModule;
import com.facebook.react.bridge.JSIModuleType;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.JavaScriptModuleRegistry;
import com.facebook.react.bridge.NativeArray;
Expand Down Expand Up @@ -75,16 +73,6 @@ public void setSourceURL(String sourceURL) {
return mSourceURL.get();
}

@Override
public @Nullable JSIModule getJSIModule(JSIModuleType moduleType) {
if (moduleType == JSIModuleType.UIManager) {
return mReactHost.getUIManager();
}
throw new UnsupportedOperationException(
"getJSIModule is not implemented for bridgeless mode. Trying to get module: "
+ moduleType.name());
}

@Override
public @Nullable UIManager getFabricUIManager() {
return mReactHost.getUIManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import android.app.Activity;
import android.content.Context;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.JSIModule;
import com.facebook.react.bridge.JSIModuleType;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
Expand Down Expand Up @@ -110,14 +108,6 @@ public boolean isBridgeless() {
return mReactApplicationContext.isBridgeless();
}

@Override
public JSIModule getJSIModule(JSIModuleType moduleType) {
if (isBridgeless()) {
return mReactApplicationContext.getJSIModule(moduleType);
}
return super.getJSIModule(moduleType);
}

@Override
public UIManager getFabricUIManager() {
if (isBridgeless()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package com.facebook.react.runtime

import android.app.Activity
import android.content.Context
import com.facebook.react.bridge.JSIModuleType
import com.facebook.react.fabric.FabricUIManager
import com.facebook.react.uimanager.UIManagerModule
import com.facebook.testutils.shadows.ShadowSoLoader
Expand Down Expand Up @@ -49,17 +48,11 @@ class BridgelessReactContextTest {
Assertions.assertThat(uiManagerModule).isEqualTo(mUiManagerModule)
}

@Test(expected = UnsupportedOperationException::class)
fun getJSIModule_throwsException() {
bridgelessReactContext.getJSIModule(JSIModuleType.TurboModuleManager)
}

@Test
fun getJSIModuleTest() {
fun getFabricUIManagerTest() {
val fabricUiManager = Mockito.mock(FabricUIManager::class.java)
doReturn(fabricUiManager).`when`(reactHost).uiManager
Assertions.assertThat(bridgelessReactContext.getJSIModule(JSIModuleType.UIManager))
.isEqualTo(fabricUiManager)
Assertions.assertThat(bridgelessReactContext.getFabricUIManager()).isEqualTo(fabricUiManager)
}

@Test(expected = UnsupportedOperationException::class)
Expand Down

0 comments on commit ce54772

Please sign in to comment.