mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Adding getFabricUIManager() APIs to ReactContext (#41728)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41728 Adding APIs for `getFabricUIManager()` to ReactContext and it's subclasses. This will replace the `getJSIModule()` post JSI module deletion. Reviewed By: philIip Differential Revision: D51718430 fbshipit-source-id: c897ab0ee9e755e3fdb3d1e5629177818870f293
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cd9b1d9e43
commit
f941f939bf
+20
@@ -26,6 +26,7 @@ import com.facebook.react.bridge.queue.MessageQueueThread;
|
||||
import com.facebook.react.bridge.queue.ReactQueueConfiguration;
|
||||
import com.facebook.react.common.LifecycleState;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
@@ -554,6 +555,25 @@ public class ReactContext extends ContextWrapper {
|
||||
return mCatalystInstance.getJSIModule(moduleType);
|
||||
}
|
||||
|
||||
@DeprecatedInNewArchitecture(
|
||||
message =
|
||||
"This method will be deprecated later as part of Stable APIs with bridge removal and not encouraged usage.")
|
||||
/**
|
||||
* Get the UIManager for Fabric from the CatalystInstance.
|
||||
*
|
||||
* @return The UIManager when CatalystInstance is active.
|
||||
*/
|
||||
public @Nullable UIManager getFabricUIManager() {
|
||||
if (!hasActiveReactInstance()) {
|
||||
throw new IllegalStateException(
|
||||
"Unable to retrieve a UIManager if CatalystInstance is not active.");
|
||||
}
|
||||
UIManager uiManager = mCatalystInstance.getFabricUIManager();
|
||||
return uiManager != null
|
||||
? uiManager
|
||||
: (UIManager) mCatalystInstance.getJSIModule(JSIModuleType.UIManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sourceURL for the JS bundle from the CatalystInstance. This method is needed for
|
||||
* compatibility with bridgeless mode, which has no CatalystInstance.
|
||||
|
||||
+6
@@ -21,6 +21,7 @@ import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactNoCrashBridgeNotAllowedSoftException;
|
||||
import com.facebook.react.bridge.ReactSoftExceptionLogger;
|
||||
import com.facebook.react.bridge.UIManager;
|
||||
import com.facebook.react.bridge.WritableNativeArray;
|
||||
import com.facebook.react.config.ReactFeatureFlags;
|
||||
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
||||
@@ -84,6 +85,11 @@ class BridgelessReactContext extends ReactApplicationContext implements EventDis
|
||||
+ moduleType.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable UIManager getFabricUIManager() {
|
||||
return mReactHost.getUIManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CatalystInstance getCatalystInstance() {
|
||||
ReactSoftExceptionLogger.logSoftExceptionVerbose(
|
||||
|
||||
+9
@@ -15,6 +15,7 @@ import com.facebook.react.bridge.JSIModuleType;
|
||||
import com.facebook.react.bridge.LifecycleEventListener;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.UIManager;
|
||||
|
||||
/**
|
||||
* Wraps {@link ReactContext} with the base {@link Context} passed into the constructor. It provides
|
||||
@@ -116,4 +117,12 @@ public class ThemedReactContext extends ReactContext {
|
||||
}
|
||||
return super.getJSIModule(moduleType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UIManager getFabricUIManager() {
|
||||
if (isBridgeless()) {
|
||||
return mReactApplicationContext.getFabricUIManager();
|
||||
}
|
||||
return super.getFabricUIManager();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user