|
22 | 22 | import com.facebook.react.bridge.ReactNoCrashSoftException; |
23 | 23 | import com.facebook.react.bridge.ReactSoftExceptionLogger; |
24 | 24 | import com.facebook.react.bridge.UIManager; |
25 | | -import com.facebook.react.config.ReactFeatureFlags; |
26 | 25 | import com.facebook.react.uimanager.common.UIManagerType; |
27 | 26 | import com.facebook.react.uimanager.events.EventDispatcher; |
| 27 | +import com.facebook.react.uimanager.events.EventDispatcherProvider; |
28 | 28 |
|
29 | 29 | /** Helper class for {@link UIManager}. */ |
30 | 30 | public class UIManagerHelper { |
@@ -53,19 +53,13 @@ private static UIManager getUIManager( |
53 | 53 | @UIManagerType int uiManagerType, |
54 | 54 | boolean returnNullIfCatalystIsInactive) { |
55 | 55 | if (context.isBridgeless()) { |
56 | | - UIManager uiManager = null; |
57 | | - if (uiManagerType == FABRIC) { |
58 | | - uiManager = (UIManager) context.getJSIModule(JSIModuleType.UIManager); |
59 | | - } else if (ReactFeatureFlags.unstable_useFabricInterop) { |
60 | | - // When Fabric Interop is enabled in Bridgeless mode, enable the legacy UIManager |
61 | | - uiManager = context.getNativeModule(UIManagerModule.class); |
62 | | - } |
63 | | - |
| 56 | + @Nullable UIManager uiManager = (UIManager) context.getJSIModule(JSIModuleType.UIManager); |
64 | 57 | if (uiManager == null) { |
65 | 58 | ReactSoftExceptionLogger.logSoftException( |
66 | 59 | TAG, |
67 | 60 | new ReactNoCrashSoftException( |
68 | 61 | "Cannot get UIManager because the instance hasn't been initialized yet.")); |
| 62 | + return null; |
69 | 63 | } |
70 | 64 | return uiManager; |
71 | 65 | } |
@@ -124,6 +118,13 @@ public static EventDispatcher getEventDispatcherForReactTag(ReactContext context |
124 | 118 | @Nullable |
125 | 119 | public static EventDispatcher getEventDispatcher( |
126 | 120 | ReactContext context, @UIManagerType int uiManagerType) { |
| 121 | + // TODO T67518514 Clean this up once we migrate everything over to bridgeless mode |
| 122 | + if (context.isBridgeless()) { |
| 123 | + if (context instanceof ThemedReactContext) { |
| 124 | + context = ((ThemedReactContext) context).getReactApplicationContext(); |
| 125 | + } |
| 126 | + return ((EventDispatcherProvider) context).getEventDispatcher(); |
| 127 | + } |
127 | 128 | UIManager uiManager = getUIManager(context, uiManagerType, false); |
128 | 129 | if (uiManager == null) { |
129 | 130 | ReactSoftExceptionLogger.logSoftException( |
|
0 commit comments