diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 8909f548371..cf143a7c6a6 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -205,10 +205,15 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { return; } + @Nullable ReactContext reactContext = getCurrentReactContext(); + if (reactContext == null) { + return; + } + EventDispatcher eventDispatcher = - UIManagerHelper.getEventDispatcher(getCurrentReactContext(), getUIManagerType()); + UIManagerHelper.getEventDispatcher(reactContext, getUIManagerType()); if (eventDispatcher != null) { - mJSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher); + mJSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher, reactContext); if (childView != null && mJSPointerDispatcher != null) { mJSPointerDispatcher.onChildStartedNativeGesture(childView, ev, eventDispatcher); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt index 1126b992da0..4e82b62376c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt @@ -37,6 +37,7 @@ import com.facebook.react.bridge.ReactContext import com.facebook.react.bridge.UiThreadUtil import com.facebook.react.bridge.WritableMap import com.facebook.react.bridge.WritableNativeMap +import com.facebook.react.common.annotations.UnstableReactNativeAPI import com.facebook.react.common.annotations.VisibleForTesting import com.facebook.react.common.build.ReactBuildConfig import com.facebook.react.config.ReactFeatureFlags @@ -619,9 +620,10 @@ public class ReactModalHostView(context: ThemedReactContext) : return super.onHoverEvent(event) } + @OptIn(UnstableReactNativeAPI::class) override fun onChildStartedNativeGesture(childView: View?, ev: MotionEvent) { eventDispatcher?.let { eventDispatcher -> - jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher) + jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher, reactContext) jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher) } }