mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Delete getJSIModule() from context (#42097)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
157cb0e02b
commit
ce54772778
-8
@@ -547,14 +547,6 @@ public class ReactContext extends ContextWrapper {
|
||||
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.")
|
||||
|
||||
-12
@@ -12,8 +12,6 @@ import com.facebook.infer.annotation.Nullsafe;
|
||||
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;
|
||||
@@ -75,16 +73,6 @@ class BridgelessReactContext extends ReactApplicationContext implements EventDis
|
||||
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();
|
||||
|
||||
-10
@@ -10,8 +10,6 @@ package com.facebook.react.uimanager;
|
||||
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;
|
||||
@@ -110,14 +108,6 @@ public class ThemedReactContext extends ReactContext {
|
||||
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()) {
|
||||
|
||||
+2
-9
@@ -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
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user