mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make events work for Fabric Interop on Bridgeless (#40941)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/40941 Events are currently not working for Fabric Interop on Bridgeless. That's because the `BridgelessReactContext` is not checking for interop modules on `getJsModule` calls, so the `InteropEventEmitter` is never returned. This extends `BridgelessReactContext` so that `InteropEventEmitter` is returned if the Interop Layer is turned on. Changelog: [Internal] [Changed] - Make events work for Fabric Interop on Bridgeless Reviewed By: cipolleschi Differential Revision: D50266484 fbshipit-source-id: 0188d71bdc7acc8c188d886d45f0258914ad7af7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
168b802a52
commit
5c2224deac
+1
-1
@@ -71,7 +71,7 @@ public class ReactContext extends ContextWrapper {
|
||||
private @Nullable JSExceptionHandler mExceptionHandlerWrapper;
|
||||
private @Nullable WeakReference<Activity> mCurrentActivity;
|
||||
|
||||
private @Nullable InteropModuleRegistry mInteropModuleRegistry;
|
||||
protected @Nullable InteropModuleRegistry mInteropModuleRegistry;
|
||||
private boolean mIsInitialized = false;
|
||||
|
||||
public ReactContext(Context base) {
|
||||
|
||||
+8
@@ -22,6 +22,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactNoCrashBridgeNotAllowedSoftException;
|
||||
import com.facebook.react.bridge.ReactSoftExceptionLogger;
|
||||
import com.facebook.react.bridge.WritableNativeArray;
|
||||
import com.facebook.react.config.ReactFeatureFlags;
|
||||
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
||||
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
||||
import com.facebook.react.uimanager.events.EventDispatcher;
|
||||
@@ -49,6 +50,9 @@ class BridgelessReactContext extends ReactApplicationContext implements EventDis
|
||||
BridgelessReactContext(Context context, ReactHostImpl host) {
|
||||
super(context);
|
||||
mReactHost = host;
|
||||
if (ReactFeatureFlags.unstable_useFabricInterop) {
|
||||
initializeInteropModules();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,6 +128,10 @@ class BridgelessReactContext extends ReactApplicationContext implements EventDis
|
||||
|
||||
@Override
|
||||
public <T extends JavaScriptModule> T getJSModule(Class<T> jsInterface) {
|
||||
if (mInteropModuleRegistry != null
|
||||
&& mInteropModuleRegistry.shouldReturnInteropModule(jsInterface)) {
|
||||
return mInteropModuleRegistry.getInteropModule(jsInterface);
|
||||
}
|
||||
JavaScriptModule interfaceProxy =
|
||||
(JavaScriptModule)
|
||||
Proxy.newProxyInstance(
|
||||
|
||||
Reference in New Issue
Block a user